Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ Removed
a C implementation of :func:`~hashlib.pbkdf2_hmac()` which is faster.
(Contributed by Victor Stinner in :gh:`94199`.)

* :mod:`xml.etree`: Remove the ``ElementTree.Element.copy()`` method of the
Comment thread
vstinner marked this conversation as resolved.
Resolved
pure Python implementation, deprecated in Python 3.10, use the
:func:`copy.copy` function instead. The C implementation of :mod:`xml.etree`
has no ``copy()`` method, only a ``__copy__()`` method.
(Contributed by Victor Stinner in :gh:`94383`.)


Porting to Python 3.12
======================
Expand Down
29 changes: 0 additions & 29 deletions Lib/test/test_xml_etree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2333,35 +2333,6 @@ def test___init__(self):
self.assertIsNot(element_foo.attrib, attrib)
self.assertNotEqual(element_foo.attrib, attrib)

def test_copy(self):
# Only run this test if Element.copy() is defined.
if "copy" not in dir(ET.Element):
raise unittest.SkipTest("Element.copy() not present")

element_foo = ET.Element("foo", { "zix": "wyp" })
element_foo.append(ET.Element("bar", { "baz": "qix" }))

with self.assertWarns(DeprecationWarning):
element_foo2 = element_foo.copy()

# elements are not the same
self.assertIsNot(element_foo2, element_foo)

# string attributes are equal
self.assertEqual(element_foo2.tag, element_foo.tag)
self.assertEqual(element_foo2.text, element_foo.text)
self.assertEqual(element_foo2.tail, element_foo.tail)

# number of children is the same
self.assertEqual(len(element_foo2), len(element_foo))

# children are the same
for (child1, child2) in itertools.zip_longest(element_foo, element_foo2):
self.assertIs(child1, child2)

# attrib is a copy
self.assertEqual(element_foo2.attrib, element_foo.attrib)

def test___copy__(self):
element_foo = ET.Element("foo", { "zix": "wyp" })
element_foo.append(ET.Element("bar", { "baz": "qix" }))
Expand Down
13 changes: 0 additions & 13 deletions Lib/xml/etree/ElementTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,6 @@ def makeelement(self, tag, attrib):
"""
return self.__class__(tag, attrib)

def copy(self):
"""Return copy of current element.

This creates a shallow copy. Subelements will be shared with the
original tree.

"""
warnings.warn(
"elem.copy() is deprecated. Use copy.copy(elem) instead.",
DeprecationWarning
)
return self.__copy__()

def __copy__(self):
elem = self.makeelement(self.tag, self.attrib)
elem.text = self.text
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:mod:`xml.etree`: Remove the ``ElementTree.Element.copy()`` method of the
pure Python implementation, deprecated in Python 3.10, use the
:func:`copy.copy` function instead. The C implementation of :mod:`xml.etree`
has no ``copy()`` method, only a ``__copy__()`` method. Patch by Victor
Stinner.