diff options
author | Mark Hammond <mhammond@skippinet.com.au> | 2001-09-05 23:42:36 +0000 |
---|---|---|
committer | Mark Hammond <mhammond@skippinet.com.au> | 2001-09-05 23:42:36 +0000 |
commit | 773c83be048ae66b7ed5329095d43e3321ac1780 (patch) | |
tree | 9e68579d8c5185b6cb48504ad4993c94ec550dd0 /Tools | |
parent | Add PyMethod_Function(), PyMethod_Self(), PyMethod_Class() back. (diff) | |
download | cpython-773c83be048ae66b7ed5329095d43e3321ac1780.tar.gz cpython-773c83be048ae66b7ed5329095d43e3321ac1780.tar.bz2 cpython-773c83be048ae66b7ed5329095d43e3321ac1780.zip |
Fix for bug #442374 - Modulefinder registry support broken
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/freeze/modulefinder.py | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/Tools/freeze/modulefinder.py b/Tools/freeze/modulefinder.py index 42cbbab038b..015708be3b0 100644 --- a/Tools/freeze/modulefinder.py +++ b/Tools/freeze/modulefinder.py @@ -47,6 +47,38 @@ class Module: s = s + ")" return s +_warned = 0 + +def _try_registry(name): + # Emulate the Registered Module support on Windows. + try: + import _winreg + RegQueryValue = _winreg.QueryValue + HKLM = _winreg.HKEY_LOCAL_MACHINE + exception = _winreg.error + except ImportError: + try: + import win32api + RegQueryValue = win32api.RegQueryValue + HKLM = 0x80000002 # HKEY_LOCAL_MACHINE + exception = win32api.error + except ImportError: + global _warned + if not _warned: + _warned = 1 + print "Warning: Neither _winreg nor win32api is available - modules" + print "listed in the registry will not be found" + return None + try: + pathname = RegQueryValue(HKLM, \ + r"Software\Python\PythonCore\%s\Modules\%s" % (sys.winver, name)) + fp = open(pathname, "rb") + except exception: + return None + else: + # XXX - To do - remove the hard code of C_EXTENSION. + stuff = "", "rb", imp.C_EXTENSION + return fp, pathname, stuff class ModuleFinder: @@ -332,20 +364,11 @@ class ModuleFinder: if name in sys.builtin_module_names: return (None, None, ("", "", imp.C_BUILTIN)) - # Emulate the Registered Module support on Windows. if sys.platform=="win32": - import _winreg - from _winreg import HKEY_LOCAL_MACHINE - try: - pathname = _winreg.QueryValueEx(HKEY_LOCAL_MACHINE, \ - "Software\\Python\\PythonCore\\%s\\Modules\\%s" % (sys.winver, name)) - fp = open(pathname, "rb") - # XXX - To do - remove the hard code of C_EXTENSION. - stuff = "", "rb", imp.C_EXTENSION - return fp, pathname, stuff - except _winreg.error: - pass - + result = _try_registry(name) + if result: + return result + path = self.path return imp.find_module(name, path) |