Skip to content

[BUG] invalid tag name with iterators in --gdb mode #5552

@tornaria

Description

@tornaria

Describe the bug

$ cat example.pyx 
def use_an_iterator(iterator):
    return (x for x in iterator)
$ cython3 --version
Cython version 3.0.0
$ cython3 -3 example.pyx 
$ cython3 -3 --gdb example.pyx 

Error compiling Cython file:
------------------------------------------------------------
...
def use_an_iterator(iterator):
^
------------------------------------------------------------

example.pyx:1:0: Compiler crash in DebugTransform


Compiler crash traceback from this point on:
  File "Cython/Compiler/Visitor.py", line 182, in Cython.Compiler.Visitor.TreeVisitor._visit
  File "/usr/lib/python3.11/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 4033, in visit_ModuleNode
    self.visit_FuncDefNode(nested_funcdef)
  File "/usr/lib/python3.11/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 4093, in visit_FuncDefNode
    self.tb.start(arg.name)
  File "/usr/lib/python3.11/site-packages/Cython/Debugger/DebugWriter.py", line 42, in start
    self.tb.start(name, attrs or {})
  File "src/lxml/saxparser.pxi", line 841, in lxml.etree.TreeBuilder.start
  File "src/lxml/saxparser.pxi", line 769, in lxml.etree.TreeBuilder._handleSaxStart
  File "src/lxml/apihelpers.pxi", line 179, in lxml.etree._makeSubElement
  File "src/lxml/apihelpers.pxi", line 1754, in lxml.etree._tagValidOrRaise
ValueError: Invalid tag name '.0'

Code to reproduce the behaviour:

def use_an_iterator(iterator):
    return (x for x in iterator)

Expected behaviour

No response

OS

linux

Python version

3.11.4

Cython version

No response

Additional context

This happens only if python lxml package is installed.

I reduced it to the simple function above, but this happens a lot in sagemath source code.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions