mirror of https://github.com/python/cpython.git
Enhancement for ModuleFinder, it can now handle _xmlplus aka PyXML.
Fixes SF # 637835.
This commit is contained in:
parent
c293704e93
commit
c7aaf953fa
|
@ -29,6 +29,17 @@ def AddPackagePath(packagename, path):
|
||||||
paths.append(path)
|
paths.append(path)
|
||||||
packagePathMap[packagename] = paths
|
packagePathMap[packagename] = paths
|
||||||
|
|
||||||
|
replacePackageMap = {}
|
||||||
|
|
||||||
|
# This ReplacePackage mechanism allows modulefinder to work around the
|
||||||
|
# way the _xmlplus package injects itself under the name "xml" into
|
||||||
|
# sys.modules at runtime by calling ReplacePackage("_xmlplus", "xml")
|
||||||
|
# before running ModuleFinder.
|
||||||
|
|
||||||
|
def ReplacePackage(oldname, newname):
|
||||||
|
replacePackageMap[oldname] = newname
|
||||||
|
|
||||||
|
|
||||||
class Module:
|
class Module:
|
||||||
|
|
||||||
def __init__(self, name, file=None, path=None):
|
def __init__(self, name, file=None, path=None):
|
||||||
|
@ -336,6 +347,9 @@ def scan_code(self, co, m):
|
||||||
|
|
||||||
def load_package(self, fqname, pathname):
|
def load_package(self, fqname, pathname):
|
||||||
self.msgin(2, "load_package", fqname, pathname)
|
self.msgin(2, "load_package", fqname, pathname)
|
||||||
|
newname = replacePackageMap.get(fqname)
|
||||||
|
if newname:
|
||||||
|
fqname = newname
|
||||||
m = self.add_module(fqname)
|
m = self.add_module(fqname)
|
||||||
m.__file__ = pathname
|
m.__file__ = pathname
|
||||||
m.__path__ = [pathname]
|
m.__path__ = [pathname]
|
||||||
|
|
Loading…
Reference in New Issue