summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-06-12 06:47:20 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-06-12 06:47:20 (GMT)
commitf0ee5ccd19ec9ad0fd6c98ebf128832c225565cd (patch)
tree6ed466bf5490987d53848f58e1c581a7b89b8c7f /Modules
parentcf2ad555113e4afc6f8cd5ac5235deef6a3fdf82 (diff)
parent9062c261a4f9268f4621548ec205c80411f75b6e (diff)
downloadcpython-f0ee5ccd19ec9ad0fd6c98ebf128832c225565cd.zip
cpython-f0ee5ccd19ec9ad0fd6c98ebf128832c225565cd.tar.gz
cpython-f0ee5ccd19ec9ad0fd6c98ebf128832c225565cd.tar.bz2
Issue #25455: Fixed a crash in repr of ElementTree.Element with recursive tag.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_elementtree.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 63639c7..b32f2ad 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -1610,10 +1610,23 @@ _elementtree_Element_remove_impl(ElementObject *self, PyObject *subelement)
static PyObject*
element_repr(ElementObject* self)
{
- if (self->tag)
- return PyUnicode_FromFormat("<Element %R at %p>", self->tag, self);
- else
+ int status;
+
+ if (self->tag == NULL)
return PyUnicode_FromFormat("<Element at %p>", self);
+
+ status = Py_ReprEnter((PyObject *)self);
+ if (status == 0) {
+ PyObject *res;
+ res = PyUnicode_FromFormat("<Element %R at %p>", self->tag, self);
+ Py_ReprLeave((PyObject *)self);
+ return res;
+ }
+ if (status > 0)
+ PyErr_Format(PyExc_RuntimeError,
+ "reentrant call inside %s.__repr__",
+ Py_TYPE(self)->tp_name);
+ return NULL;
}
/*[clinic input]