]> granicus.if.org Git - python/commitdiff
Application of [ Patch #102226 ] freeze/modulefinder.py should use _winreg, not win32api
authorMark Hammond <mhammond@skippinet.com.au>
Mon, 6 Nov 2000 02:49:27 +0000 (02:49 +0000)
committerMark Hammond <mhammond@skippinet.com.au>
Mon, 6 Nov 2000 02:49:27 +0000 (02:49 +0000)
Tools/freeze/modulefinder.py

index e84a54128f6f932c000fb35701c47ac72a9edb34..8c4b74d442f974cf7b0b69765cf7f98b618659b7 100644 (file)
@@ -8,17 +8,6 @@ import re
 import string
 import sys
 
-if sys.platform=="win32":
-    # On Windows, we can locate modules in the registry with
-    # the help of the win32api package.
-    try:
-        import win32api
-    except ImportError:
-        print "The win32api module is not available - modules listed"
-        print "in the registry will not be found."
-        win32api = None
-
-
 IMPORT_NAME = dis.opname.index('IMPORT_NAME')
 IMPORT_FROM = dis.opname.index('IMPORT_FROM')
 STORE_NAME = dis.opname.index('STORE_NAME')
@@ -339,15 +328,17 @@ class ModuleFinder:
                 return (None, None, ("", "", imp.C_BUILTIN))
 
             # Emulate the Registered Module support on Windows.
-            if sys.platform=="win32" and win32api is not None:
-                HKEY_LOCAL_MACHINE = 0x80000002
+            if sys.platform=="win32":
+                import _winreg
+                from _winreg import HKEY_LOCAL_MACHINE
                 try:
-                    pathname = win32api.RegQueryValue(HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore\\%s\\Modules\\%s" % (sys.winver, name))
+                    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 win32api.error:
+                except _winreg.error:
                     pass
 
             path = self.path