Commits

Christian Heimes  committed eb9ab60

load files from build/lib*

  • Participants
  • Parent commits 44d3046

Comments (0)

Files changed (2)

File defusedexpat.py

     """
     if modname in sys.modules:
         raise ValueError("%s already loaded" % modname)
+    searchpath = [HERE]
+    if "DEFUSED_EXPAT" in os.environ:
+        # for unit testing
+        searchpath.extend(os.environ["DEFUSED_EXPAT"].split(os.pathsep))
+    fh = None
     try:
-        fh, filename, description = imp.find_module(modname, [HERE])
+        fh, filename, description = imp.find_module(modname, searchpath)
         mod = imp.load_module(modname, fh, filename, description)
     finally:
-        fh.close()
+        if fh is not None:
+            fh.close()
     modpath = getattr(sys.modules[modname], "__file__", "")
     if not modpath.startswith(HERE):
         raise ValueError("Unpatched module %r loaded (%s != %s)" %
         libdirs = self.get_lib_dirs()
         # add lib dirs to Python's search path
         env = os.environ.copy()
-        env["PYTHONPATH"] = os.pathsep.join(libdirs)
+        env["PYTHONPATH"] = env["DEFUSED_EXPAT"] = os.pathsep.join(libdirs)
         # and finally run the test command
         errno = subprocess.check_call([sys.executable, "tests.py"], env=env)
         raise SystemExit(errno)
 
+
 moddir = "Modules%i%i" % sys.version_info[0:2]
 exts = []
 expat_inc = [os.path.join(os.getcwd(), 'expat')]
     name="defusedexpat",
     version="0.1",
     ext_modules=exts,
-    py_modules=["defuxedexpat"],
+    py_modules=["defusedexpat"],
     cmdclass={"test": TestCommand},
     author="Christian Heimes",
     author_email="christian@python.org",