[pypy-commit] pypy release-5.x: An arguably bogus check in the stdlib.

arigo pypy.commits at gmail.com
Wed Mar 9 11:15:09 EST 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: release-5.x
Changeset: r82913:246c9cf22037
Date: 2016-03-09 16:34 +0100
http://bitbucket.org/pypy/pypy/changeset/246c9cf22037/

Log:	An arguably bogus check in the stdlib.

diff --git a/lib-python/2.7/xml/etree/ElementTree.py b/lib-python/2.7/xml/etree/ElementTree.py
--- a/lib-python/2.7/xml/etree/ElementTree.py
+++ b/lib-python/2.7/xml/etree/ElementTree.py
@@ -1606,7 +1606,17 @@
                     pubid = pubid[1:-1]
                 if hasattr(self.target, "doctype"):
                     self.target.doctype(name, pubid, system[1:-1])
-                elif self.doctype is not self._XMLParser__doctype:
+                elif 1:  # XXX PyPy fix, used to be
+                         #   elif self.doctype is not self._XMLParser__doctype:
+                         # but that condition is always True on CPython, as far
+                         # as I can tell: self._XMLParser__doctype always
+                         # returns a fresh unbound method object.
+                         # On PyPy, unbound and bound methods have stronger
+                         # unicity guarantees: self._XMLParser__doctype
+                         # can return the same unbound method object, in
+                         # some cases making the test above incorrectly False.
+                         # (My guess would be that the line above is a backport
+                         # from Python 3.)
                     # warn about deprecated call
                     self._XMLParser__doctype(name, pubid, system[1:-1])
                     self.doctype(name, pubid, system[1:-1])


More information about the pypy-commit mailing list