-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Open
Description
I've noticed odd behaviour when IPython tries to render a traceback for a ParseError in etree, which only happens in IPython 9.6.0.
The code which causes this behaviour is:
from xml.etree import ElementTree
ElementTree.fromstring("hello")In 9.5.0:
In [1]: from xml.etree import ElementTree
...:
...: ElementTree.fromstring("hello")
Traceback (most recent call last):
File ~/.virtualenvs/ucedpy/lib/python3.13/site-packages/IPython/core/interactiveshell.py:3699 in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
Cell In[1], line 3
ElementTree.fromstring("hello")
File /usr/lib/python3.13/xml/etree/ElementTree.py:1349 in XML
return parser.close()
File <string>
ParseError: syntax error: line 1, column 0The ParseError is raised and the traceback is rendered fine.
In 9.6.0:
...
File ~/.virtualenvs/ucedpy/lib/python3.13/site-packages/IPython/core/ultratb.py:341, in ListTB._format_exception_only(self, etype, value)
327 output_list.append(
328 theme_table[self._theme_name].format(
329 [(Token, " ")]
(...) 336 )
337 )
338 if textline == "":
339 # sep 2025:
340 # textline = py3compat.cast_unicode(value.text, "utf-8")
--> 341 assert isinstance(value.text, str)
342 textline = value.text
344 if textline is not None:
AssertionError:It hits a branch of code with the comment sep 2025 and fails an assert.
Metadata
Metadata
Assignees
Labels
No labels