Skip to content

bpo-32424: Rename copy() to __copy__() in Python version of xml.etree.ElementTree. #5022

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

Closed
wants to merge 1 commit into from

Conversation

GPHemsley
Copy link
Contributor

@GPHemsley GPHemsley commented Dec 27, 2017

The C version defines __copy__() and __deepcopy__() while the Python
version defines copy(). The documentation does not mention copy(), so
it is presumed to be in error. This unifies the definition of __copy__()
between the Python and C version, making the proper way to copy an
Element be copy.copy(ET.Element("foo")).

https://bugs.python.org/issue32424

….ElementTree.

The C version defines __copy__() and __deepcopy__() while the Python
version defines copy(). The documentation does not mention copy(), so
it is presumed to be in error. This unifies the definition of __copy__()
between the Python and C version, making the proper way to copy an
Element be copy.copy(ET.Element("foo")).
@GPHemsley GPHemsley changed the title Rename copy() to __copy__() in Python version of xml.etree.ElementTree. bpo-32424: Rename copy() to __copy__() in Python version of xml.etree.ElementTree. Dec 27, 2017
@@ -189,7 +189,7 @@ def makeelement(self, tag, attrib):
"""
return self.__class__(tag, attrib)

def copy(self):
def __copy__(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this breaks the public API. I think we could do it in this way, keep the copy() method and alias it to __copy__.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you feel strongly about it, leave a comment on the bpo ticket. It may be worth having a discussion about what constitutes the "public" API in this case.

@GPHemsley
Copy link
Contributor Author

Consensus is that this is not the right approach.

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

Successfully merging this pull request may close these issues.

4 participants