[Python-checkins] CVS: python/dist/src/Tools/freeze modulefinder.py,1.16,1.17
Mark Hammond
mhammond@users.sourceforge.net
Wed, 05 Sep 2001 16:42:38 -0700
Update of /cvsroot/python/python/dist/src/Tools/freeze
In directory usw-pr-cvs1:/tmp/cvs-serv10313
Modified Files:
modulefinder.py
Log Message:
Fix for bug #442374 - Modulefinder registry support broken
Index: modulefinder.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/freeze/modulefinder.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** modulefinder.py 2001/03/20 20:43:34 1.16
--- modulefinder.py 2001/09/05 23:42:36 1.17
***************
*** 48,52 ****
--- 48,84 ----
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:
***************
*** 333,350 ****
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
!
path = self.path
return imp.find_module(name, path)
--- 365,373 ----
return (None, None, ("", "", imp.C_BUILTIN))
if sys.platform=="win32":
! result = _try_registry(name)
! if result:
! return result
!
path = self.path
return imp.find_module(name, path)