Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml.etree.ElementTree fails to parse a document (regression) #75484

Closed
VyacheslavRafalskiy mannequin opened this issue Aug 29, 2017 · 3 comments
Closed

xml.etree.ElementTree fails to parse a document (regression) #75484

VyacheslavRafalskiy mannequin opened this issue Aug 29, 2017 · 3 comments
Assignees
Labels
3.7 (EOL) end of life topic-XML type-bug An unexpected behavior, bug, or error

Comments

@VyacheslavRafalskiy
Copy link
Mannequin

VyacheslavRafalskiy mannequin commented Aug 29, 2017

BPO 31303
Nosy @vstinner, @serhiy-storchaka
Superseder
  • bpo-31170: Update to expat 2.2.4 (expat: utf8_toUtf8 cannot properly handle exhausting buffer)
  • Files
  • bad_file.xml
  • bad_file.xml
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2017-08-30.05:15:12.619>
    created_at = <Date 2017-08-29.17:45:53.331>
    labels = ['expert-XML', 'type-bug', '3.7']
    title = 'xml.etree.ElementTree fails to parse a document (regression)'
    updated_at = <Date 2017-08-30.05:15:12.566>
    user = 'https://bugs.python.org/VyacheslavRafalskiy'

    bugs.python.org fields:

    activity = <Date 2017-08-30.05:15:12.566>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2017-08-30.05:15:12.619>
    closer = 'serhiy.storchaka'
    components = ['XML']
    creation = <Date 2017-08-29.17:45:53.331>
    creator = 'Vyacheslav.Rafalskiy'
    dependencies = []
    files = ['47108', '47109']
    hgrepos = []
    issue_num = 31303
    keywords = []
    message_count = 3.0
    messages = ['300996', '300997', '301010']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'serhiy.storchaka', 'Vyacheslav.Rafalskiy']
    pr_nums = []
    priority = 'critical'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '31170'
    type = 'behavior'
    url = 'https://bugs.python.org/issue31303'
    versions = ['Python 3.6', 'Python 3.7']

    @VyacheslavRafalskiy
    Copy link
    Mannequin Author

    VyacheslavRafalskiy mannequin commented Aug 29, 2017

    In Python 3.5.4 and 3.6.2, both on Windows and Linux, parsing a manifestly correct xml file like:

    xml.etree.ElementTree.parse('bad_file.xml')

    raises:
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 1023: invalid continuation byte

    Any other Python version I tried works fine, including 2.7.13, 3.5.2 ...

    @VyacheslavRafalskiy VyacheslavRafalskiy mannequin added type-crash A hard crash of the interpreter, possibly with a core dump topic-XML labels Aug 29, 2017
    @serhiy-storchaka serhiy-storchaka added the 3.7 (EOL) end of life label Aug 29, 2017
    @serhiy-storchaka serhiy-storchaka self-assigned this Aug 29, 2017
    @serhiy-storchaka serhiy-storchaka added type-bug An unexpected behavior, bug, or error and removed type-crash A hard crash of the interpreter, possibly with a core dump labels Aug 29, 2017
    @serhiy-storchaka
    Copy link
    Member

    Simpler reproducer:

    >>> import xml.etree.ElementTree
    >>> xml.etree.ElementTree.XML(b'<key attr="' + b'x'*1023 + b'\xc3\xa0&quot;"/>')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/serhiy/py/cpython/Lib/xml/etree/ElementTree.py", line 1315, in XML
        parser.feed(text)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 1023: invalid continuation byte

    Seems this is a regression in the Expat library.

    @serhiy-storchaka
    Copy link
    Member

    This is a duplicate of bpo-31170. Updating expat to 2.2.4 fixes this issue.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life topic-XML type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant