From bba6537f97add52430b0dd2cbcb52da0dda2496c Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 23 Jul 2013 18:09:44 +0000 Subject: [PATCH] Fix VFSImporter for modules that change their sys.modules definition (such as 'Pmw' and 'panda3d') --- direct/src/showbase/VFSImporter.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/direct/src/showbase/VFSImporter.py b/direct/src/showbase/VFSImporter.py index 4834008dad..217a330452 100644 --- a/direct/src/showbase/VFSImporter.py +++ b/direct/src/showbase/VFSImporter.py @@ -143,15 +143,15 @@ class VFSLoader: if not code: raise ImportError, 'No Python code in %s' % (fullname) - mod = sys.modules.setdefault(fullname, new.module(fullname)) + mod = sys.modules.setdefault(fullname, imp.new_module(fullname)) mod.__file__ = self.filename.toOsSpecific() mod.__loader__ = self if self.packagePath: mod.__path__ = [self.packagePath.toOsSpecific()] #print >> sys.stderr, "loaded %s, path = %s" % (fullname, mod.__path__) - exec code in mod.__dict__ - return mod + exec(code, mod.__dict__) + return sys.modules[fullname] def getdata(self, path): path = Filename(self.dir_path, Filename.fromOsSpecific(path)) @@ -514,5 +514,4 @@ def reloadSharedPackages(): continue reloadSharedPackage(mod) - - +