Subscript numbers result in invalid literal for int() with base 10

Bug #2008911 reported by Alex Hippel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Fix Released
Medium
Unassigned

Bug Description

In the latest release when parsing only subscripted digits it seems to decide they are digits but then throws an exception: ValueError: invalid literal for int() with base 10.

This did not happen with an earlier release.

Code to reproduce:

from lxml import objectify
xml = """
<types>
<mytext>abc</mytext>
<mynum>123</mynum>
<mysuperscript>²²²²²²²²²²</mysuperscript>
</types>
"""
doc = objectify.fromstring(xml)
print(objectify.dump(doc))

Result in the latest release:

Traceback (most recent call last):
  File "/home/ubuntu/dev/scratch_18.py", line 11, in <module>
    print(objectify.dump(doc))
          ^^^^^^^^^^^^^^^^^^^
  File "src/lxml/objectify.pyx", line 1521, in lxml.objectify.dump
  File "src/lxml/objectify.pyx", line 1549, in lxml.objectify._dump
  File "src/lxml/objectify.pyx", line 1526, in lxml.objectify._dump
  File "src/lxml/objectify.pyx", line 646, in lxml.objectify.NumberElement.__repr__
  File "src/lxml/objectify.pyx", line 946, in lxml.objectify._parseNumber
ValueError: invalid literal for int() with base 10: '²²²²²²²²²²'

Not working with the following:
Python : sys.version_info(major=3, minor=11, micro=1, releaselevel='final', serial=0)
lxml.etree : (4, 9, 2, 0)
libxml used : (2, 9, 14)
libxml compiled : (2, 9, 14)
libxslt used : (1, 1, 35)
libxslt compiled : (1, 1, 35)

Working with the following:
Python : sys.version_info(major=3, minor=9, micro=4, releaselevel='final', serial=0)
lxml.etree : (4, 5, 1, 0)
libxml used : (2, 9, 4)
libxml compiled : (2, 9, 4)
libxslt used : (1, 1, 29)
libxslt compiled : (1, 1, 29)

scoder (scoder)
Changed in lxml:
milestone: none → 4.9.3
importance: Undecided → Medium
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.