|
| 1 | +diff --git a/Cython/Debugger/DebugWriter.py b/Cython/Debugger/DebugWriter.py |
| 2 | +index 8b1fb75b027..2c3c310fc64 100644 |
| 3 | +--- a/Cython/Debugger/DebugWriter.py |
| 4 | ++++ b/Cython/Debugger/DebugWriter.py |
| 5 | +@@ -18,6 +18,21 @@ |
| 6 | + etree = None |
| 7 | + |
| 8 | + from ..Compiler import Errors |
| 9 | ++from ..Compiler.StringEncoding import EncodedString |
| 10 | ++ |
| 11 | ++ |
| 12 | ++def is_valid_tag(name): |
| 13 | ++ """ |
| 14 | ++ Names like '.0' are used internally for arguments |
| 15 | ++ to functions creating generator expressions, |
| 16 | ++ however they are not identifiers. |
| 17 | ++ |
| 18 | ++ See https://github.com/cython/cython/issues/5552 |
| 19 | ++ """ |
| 20 | ++ if isinstance(name, EncodedString): |
| 21 | ++ if name.startswith(".") and name[1:].isdecimal(): |
| 22 | ++ return False |
| 23 | ++ return True |
| 24 | + |
| 25 | + |
| 26 | + class CythonDebugWriter(object): |
| 27 | +@@ -39,14 +54,17 @@ def __init__(self, output_dir): |
| 28 | + self.start('cython_debug', attrs=dict(version='1.0')) |
| 29 | + |
| 30 | + def start(self, name, attrs=None): |
| 31 | +- self.tb.start(name, attrs or {}) |
| 32 | ++ if is_valid_tag(name): |
| 33 | ++ self.tb.start(name, attrs or {}) |
| 34 | + |
| 35 | + def end(self, name): |
| 36 | +- self.tb.end(name) |
| 37 | ++ if is_valid_tag(name): |
| 38 | ++ self.tb.end(name) |
| 39 | + |
| 40 | + def add_entry(self, name, **attrs): |
| 41 | +- self.tb.start(name, attrs) |
| 42 | +- self.tb.end(name) |
| 43 | ++ if is_valid_tag(name): |
| 44 | ++ self.tb.start(name, attrs) |
| 45 | ++ self.tb.end(name) |
| 46 | + |
| 47 | + def serialize(self): |
| 48 | + self.tb.end('Module') |
0 commit comments