diff options
author | nik-bes <[email protected]> | 2025-05-19 07:20:13 +0300 |
---|---|---|
committer | nik-bes <[email protected]> | 2025-05-19 07:36:02 +0300 |
commit | 317b7368e24941ff76499f500579fd9b10f6656e (patch) | |
tree | abbcbaea595e7d2e9f23cf59a408b3082fe4340d /contrib/tools/cython/Cython/Debugger/DebugWriter.py | |
parent | 6b666a52d40308ab9b3532cd8d3008b9f37cfffb (diff) |
Update Cython to 3.0.10.
commit_hash:b43c96b868cd36d636192fd2c6024d9f0d2fb6f8
Diffstat (limited to 'contrib/tools/cython/Cython/Debugger/DebugWriter.py')
-rw-r--r-- | contrib/tools/cython/Cython/Debugger/DebugWriter.py | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/contrib/tools/cython/Cython/Debugger/DebugWriter.py b/contrib/tools/cython/Cython/Debugger/DebugWriter.py index 876a3a2169a..2c3c310fc64 100644 --- a/contrib/tools/cython/Cython/Debugger/DebugWriter.py +++ b/contrib/tools/cython/Cython/Debugger/DebugWriter.py @@ -5,8 +5,8 @@ import sys import errno try: - from lxml import etree - have_lxml = True + from lxml import etree + have_lxml = True except ImportError: have_lxml = False try: @@ -18,6 +18,21 @@ except ImportError: etree = None from ..Compiler import Errors +from ..Compiler.StringEncoding import EncodedString + + +def is_valid_tag(name): + """ + Names like '.0' are used internally for arguments + to functions creating generator expressions, + however they are not identifiers. + + See https://github.com/cython/cython/issues/5552 + """ + if isinstance(name, EncodedString): + if name.startswith(".") and name[1:].isdecimal(): + return False + return True class CythonDebugWriter(object): @@ -39,14 +54,17 @@ class CythonDebugWriter(object): self.start('cython_debug', attrs=dict(version='1.0')) def start(self, name, attrs=None): - self.tb.start(name, attrs or {}) + if is_valid_tag(name): + self.tb.start(name, attrs or {}) def end(self, name): - self.tb.end(name) + if is_valid_tag(name): + self.tb.end(name) def add_entry(self, name, **attrs): - self.tb.start(name, attrs) - self.tb.end(name) + if is_valid_tag(name): + self.tb.start(name, attrs) + self.tb.end(name) def serialize(self): self.tb.end('Module') |