Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
773c83be
Commit
773c83be
authored
Sep 05, 2001
by
Mark Hammond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for bug #442374 - Modulefinder registry support broken
parent
b479dc56
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
13 deletions
+36
-13
Tools/freeze/modulefinder.py
Tools/freeze/modulefinder.py
+36
-13
No files found.
Tools/freeze/modulefinder.py
View file @
773c83be
...
...
@@ -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\
Py
thon\
Py
thonCore\
%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)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment