[issue38611] ElementTree.ParseError does not implement SyntaxError interface as expected

Jim Carroll report at bugs.python.org
Tue Oct 29 18:46:43 EDT 2019


Jim Carroll <jim at carroll.com> added the comment:

This patch solves the issue

diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index c3f30c9339..d265021f75 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -2782,6 +2782,7 @@ treebuilder_handle_start(TreeBuilderObject* self, PyObject* tag,
                 st->parseerror_obj,
                 "multiple elements on top level"
                 );
+                       PyErr_SyntaxLocationEx("xml.etree.ElementTree", 0, 0);
             goto error;
         }
         Py_INCREF(node);
@@ -3267,6 +3268,7 @@ expat_set_error(enum XML_Error error_code, Py_ssize_t line, Py_ssize_t column,
     Py_DECREF(position);

     PyErr_SetObject(st->parseerror_obj, error);
+       PyErr_SyntaxLocationEx("xml.etree.ElementTree", (int)line, (int)column);
     Py_DECREF(error);
 }

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38611>
_______________________________________


More information about the Python-bugs-list mailing list