mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Fix repr of tree Element on windows.
This commit is contained in:
parent
3e8c189faa
commit
e2e81e8fcd
2 changed files with 12 additions and 10 deletions
|
@ -131,7 +131,7 @@ def check_element(element):
|
||||||
# element tree tests
|
# element tree tests
|
||||||
|
|
||||||
def interface():
|
def interface():
|
||||||
"""
|
r"""
|
||||||
Test element tree interface.
|
Test element tree interface.
|
||||||
|
|
||||||
>>> element = ET.Element("tag")
|
>>> element = ET.Element("tag")
|
||||||
|
@ -139,10 +139,11 @@ def interface():
|
||||||
>>> tree = ET.ElementTree(element)
|
>>> tree = ET.ElementTree(element)
|
||||||
>>> check_element(tree.getroot())
|
>>> check_element(tree.getroot())
|
||||||
|
|
||||||
>>> element = ET.Element("tag", key="value")
|
>>> element = ET.Element("t\xe4g", key="value")
|
||||||
>>> tree = ET.ElementTree(element)
|
>>> tree = ET.ElementTree(element)
|
||||||
>>> repr(element) # doctest: +ELLIPSIS
|
>>> repr(element) # doctest: +ELLIPSIS
|
||||||
"<Element 'tag' at 0x...>"
|
"<Element 't\\xe4g' at 0x...>"
|
||||||
|
>>> element = ET.Element("tag", key="value")
|
||||||
|
|
||||||
Make sure all standard element methods exist.
|
Make sure all standard element methods exist.
|
||||||
|
|
||||||
|
|
|
@ -1190,15 +1190,16 @@ element_remove(ElementObject* self, PyObject* args)
|
||||||
static PyObject*
|
static PyObject*
|
||||||
element_repr(ElementObject* self)
|
element_repr(ElementObject* self)
|
||||||
{
|
{
|
||||||
PyObject* repr;
|
PyObject *repr, *tag;
|
||||||
char buffer[100];
|
|
||||||
|
|
||||||
repr = PyString_FromString("<Element ");
|
|
||||||
|
|
||||||
PyString_ConcatAndDel(&repr, PyObject_Repr(self->tag));
|
tag = PyObject_Repr(self->tag);
|
||||||
|
if (!tag)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
sprintf(buffer, " at %p>", self);
|
repr = PyString_FromFormat("<Element %s at %p>",
|
||||||
PyString_ConcatAndDel(&repr, PyString_FromString(buffer));
|
PyString_AS_STRING(tag), self);
|
||||||
|
|
||||||
|
Py_DECREF(tag);
|
||||||
|
|
||||||
return repr;
|
return repr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue