On 07/26/2012 09:10 AM, David Malcolm wrote:
I did some investigating of how to do this.
The replacement of xml with PyXML in the stdlib happens in
xml/__init__.py (see e.g. /usr/lib64/python2.7/xml/__init__.py): as
"xml" is imported, it tries to import _xmlplus, and if
_xmlplus.version_info >= (0, 8, 4) it replaces sys.modules[__name__]
with _xmlplus, effectively replacing "xml" with "_xmlplus".
I suggest a different tactic. Try replacing the line:
_xmlplus.__path__.extend(__path__)
with
_xmlplus.__path__[0:0] = __path__
At the moment, the replacement works as follows:
1. Both the stdlib and PyXML package dirs are on the package path
2. In the case of name clashes, prefer the PyXML version
By changing it to put the stdlib path first, you would instead set up
the following:
1. Both the stdlib and PyXML package dirs are on the package path
2. In the case of name clashes, prefer the stdlib version
(This should work, because PyXML doesn't import anything implicitly in
__init__.py)
Since Toshio reports that the current behaviour is genuinely causing
problems, you could probably make a case for this approach as an
upstream bugfix, especially if you implement it in Fedora first with no
apparent ill-effects for affected applications.
Cheers,
Nick.
--
Nick Coghlan
Red Hat Infrastructure Engineering & Development, Brisbane