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

Make XMLSyntaxError have normal SyntaxError metadata #217

Merged
merged 1 commit into from Dec 6, 2016

Conversation

Projects
None yet
2 participants
@flying-sheep
Contributor

flying-sheep commented Dec 4, 2016

Some tools (e.g. IPython) show a special error message like the following if common SyntaxError metadata is available:

$ PYTHONPATH=src ipython
In [1]: from lxml import etree
In [2]: etree.parse('src/lxml/tests/test_broken.xml')
  File "src/lxml/tests/test_broken.xml", line 1
    <a><b></c></b></a>
             ^
XMLSyntaxError: Opening and ending tag mismatch: b line 1 and c, line 1, column 11

This PR adds the necessary fields filename, lineno and offset, while making position a property in order to keep it in sync with lineno and offset if those are changed.

self.assertEqual(e.lineno, 1)
self.assertEqual(e.offset, 10)
except Exception as e:
self.fail('{}, not {}'.format(fail_msg, type(e)))

This comment has been minimized.

@scoder

scoder Dec 6, 2016

Member

Empty format keys aren't supported in Py2.6.

@scoder

scoder Dec 6, 2016

Member

Empty format keys aren't supported in Py2.6.

@scoder

This comment has been minimized.

Show comment
Hide comment
@scoder

scoder Dec 6, 2016

Member

Cool, really nice feature.

Member

scoder commented Dec 6, 2016

Cool, really nice feature.

@scoder scoder merged commit 445762d into lxml:master Dec 6, 2016

@flying-sheep flying-sheep deleted the flying-sheep:syntax-error-meta branch Dec 6, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment