Skip to content

Commit 2f48d89

Browse files
committed
Stop trying to use _xmlplus in the xml module. Closes #11164.
Patch by Arfrever Frehtes Taifersar Arahesis.
1 parent 8269a44 commit 2f48d89

File tree

9 files changed

+10
-105
lines changed

9 files changed

+10
-105
lines changed

Doc/distutils/introduction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ modules using the Distutils:
187187
module distribution
188188
a collection of Python modules distributed together as a single downloadable
189189
resource and meant to be installed *en masse*. Examples of some well-known
190-
module distributions are Numeric Python, PyXML, PIL (the Python Imaging
190+
module distributions are NumPy, SciPy, PIL (the Python Imaging
191191
Library), or mxBase. (This would be called a *package*, except that term is
192192
already taken in the Python context: a single module distribution may contain
193193
zero, one, or many Python packages.)

Doc/library/modulefinder.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ report of the imported modules will be printed.
2222
.. function:: ReplacePackage(oldname, newname)
2323

2424
Allows specifying that the module named *oldname* is in fact the package named
25-
*newname*. The most common usage would be to handle how the :mod:`_xmlplus`
26-
package replaces the :mod:`xml` package.
25+
*newname*.
2726

2827

2928
.. class:: ModuleFinder(path=None, debug=0, excludes=[], replace_paths=[])

Doc/library/xml.dom.minidom.rst

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,8 @@ functions do not provide a parser implementation themselves.
5757
You can also create a :class:`Document` by calling a method on a "DOM
5858
Implementation" object. You can get this object either by calling the
5959
:func:`getDOMImplementation` function in the :mod:`xml.dom` package or the
60-
:mod:`xml.dom.minidom` module. Using the implementation from the
61-
:mod:`xml.dom.minidom` module will always return a :class:`Document` instance
62-
from the minidom implementation, while the version from :mod:`xml.dom` may
63-
provide an alternate implementation (this is likely if you have the `PyXML
64-
package <http://pyxml.sourceforge.net/>`_ installed). Once you have a
65-
:class:`Document`, you can add child nodes to it to populate the DOM::
60+
:mod:`xml.dom.minidom` module. Once you have a :class:`Document`, you
61+
can add child nodes to it to populate the DOM::
6662

6763
from xml.dom.minidom import getDOMImplementation
6864

Doc/library/xml.dom.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ The Document Object Model is being defined by the W3C in stages, or "levels" in
3030
their terminology. The Python mapping of the API is substantially based on the
3131
DOM Level 2 recommendation.
3232

33-
.. XXX PyXML is dead...
34-
.. The mapping of the Level 3 specification, currently
35-
only available in draft form, is being developed by the `Python XML Special
36-
Interest Group <http://www.python.org/sigs/xml-sig/>`_ as part of the `PyXML
37-
package <http://pyxml.sourceforge.net/>`_. Refer to the documentation bundled
38-
with that package for information on the current state of DOM Level 3 support.
39-
4033
.. What if your needs are somewhere between SAX and the DOM? Perhaps
4134
you cannot afford to load the entire tree in memory but you find the
4235
SAX model somewhat cumbersome and low-level. There is also a module

Lib/modulefinder.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ def AddPackagePath(packagename, path):
3535

3636
replacePackageMap = {}
3737

38-
# This ReplacePackage mechanism allows modulefinder to work around the
39-
# way the _xmlplus package injects itself under the name "xml" into
40-
# sys.modules at runtime by calling ReplacePackage("_xmlplus", "xml")
38+
# This ReplacePackage mechanism allows modulefinder to work around
39+
# situations in which a package injects itself under the name
40+
# of another package into sys.modules at runtime by calling
41+
# ReplacePackage("real_package_name", "faked_package_name")
4142
# before running ModuleFinder.
4243

4344
def ReplacePackage(oldname, newname):

Lib/test/test_minidom.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,6 @@ def create_doc_with_doctype():
5151
return doc
5252

5353
class MinidomTest(unittest.TestCase):
54-
def tearDown(self):
55-
try:
56-
Node.allnodes
57-
except AttributeError:
58-
# We don't actually have the minidom from the standard library,
59-
# but are picking up the PyXML version from site-packages.
60-
pass
61-
else:
62-
self.confirm(len(Node.allnodes) == 0,
63-
"assertion: len(Node.allnodes) == 0")
64-
if len(Node.allnodes):
65-
print("Garbage left over:")
66-
if verbose:
67-
print(list(Node.allnodes.items())[0:10])
68-
else:
69-
# Don't print specific nodes if repeatable results
70-
# are needed
71-
print(len(Node.allnodes))
72-
Node.allnodes = {}
73-
7454
def confirm(self, test, testname = "Test"):
7555
self.assertTrue(test, testname)
7656

Lib/test/test_sax.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -694,51 +694,6 @@ def test_nsattrs_wattr(self):
694694
self.assertEqual(attrs.getQNameByName((ns_uri, "attr")), "ns:attr")
695695

696696

697-
# During the development of Python 2.5, an attempt to move the "xml"
698-
# package implementation to a new package ("xmlcore") proved painful.
699-
# The goal of this change was to allow applications to be able to
700-
# obtain and rely on behavior in the standard library implementation
701-
# of the XML support without needing to be concerned about the
702-
# availability of the PyXML implementation.
703-
#
704-
# While the existing import hackery in Lib/xml/__init__.py can cause
705-
# PyXML's _xmlpus package to supplant the "xml" package, that only
706-
# works because either implementation uses the "xml" package name for
707-
# imports.
708-
#
709-
# The move resulted in a number of problems related to the fact that
710-
# the import machinery's "package context" is based on the name that's
711-
# being imported rather than the __name__ of the actual package
712-
# containment; it wasn't possible for the "xml" package to be replaced
713-
# by a simple module that indirected imports to the "xmlcore" package.
714-
#
715-
# The following two tests exercised bugs that were introduced in that
716-
# attempt. Keeping these tests around will help detect problems with
717-
# other attempts to provide reliable access to the standard library's
718-
# implementation of the XML support.
719-
720-
def test_sf_1511497(self):
721-
# Bug report: http://www.python.org/sf/1511497
722-
import sys
723-
old_modules = sys.modules.copy()
724-
for modname in list(sys.modules.keys()):
725-
if modname.startswith("xml."):
726-
del sys.modules[modname]
727-
try:
728-
import xml.sax.expatreader
729-
module = xml.sax.expatreader
730-
self.assertEqual(module.__name__, "xml.sax.expatreader")
731-
finally:
732-
sys.modules.update(old_modules)
733-
734-
def test_sf_1513611(self):
735-
# Bug report: http://www.python.org/sf/1513611
736-
sio = StringIO("invalid")
737-
parser = make_parser()
738-
from xml.sax import SAXParseException
739-
self.assertRaises(SAXParseException, parser.parse, sio)
740-
741-
742697
def test_main():
743698
run_unittest(MakeParserTest,
744699
SaxutilsTest,

Lib/xml/__init__.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,3 @@
1818

1919

2020
__all__ = ["dom", "parsers", "sax", "etree"]
21-
22-
_MINIMUM_XMLPLUS_VERSION = (0, 8, 4)
23-
24-
25-
try:
26-
import _xmlplus
27-
except ImportError:
28-
pass
29-
else:
30-
try:
31-
v = _xmlplus.version_info
32-
except AttributeError:
33-
# _xmlplus is too old; ignore it
34-
pass
35-
else:
36-
if v >= _MINIMUM_XMLPLUS_VERSION:
37-
import sys
38-
_xmlplus.__path__.extend(__path__)
39-
sys.modules[__name__] = _xmlplus
40-
else:
41-
del v

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ Core and Builtins
6666
Library
6767
-------
6868

69+
- Issue #11164: Stop trying to use _xmlplus in the xml module.
70+
6971
- Issue #11927: SMTP_SSL now uses port 465 by default as documented. Patch
7072
by Kasun Herath.
7173

0 commit comments

Comments
 (0)