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
fec3ad10
Commit
fec3ad10
authored
May 14, 2011
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change import_fresh_module to work with packages.
parent
7c404891
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
10 deletions
+6
-10
Lib/test/support.py
Lib/test/support.py
+6
-10
No files found.
Lib/test/support.py
View file @
fec3ad10
...
...
@@ -80,19 +80,15 @@ def import_module(name, deprecated=False):
def
_save_and_remove_module
(
name
,
orig_modules
):
"""Helper function to save and remove a module from sys.modules
Return True if the module was in sys.modules, False otherwise.
Raise ImportError if the module can't be imported."""
saved
=
True
try
:
orig_modules
[
name
]
=
sys
.
modules
[
name
]
except
KeyError
:
# try to import the module and raise an error if it can't be imported
# try to import the module and raise an error if it can't be imported
if
name
not
in
sys
.
modules
:
__import__
(
name
)
saved
=
False
else
:
del
sys
.
modules
[
name
]
return
saved
for
modname
in
list
(
sys
.
modules
):
if
modname
==
name
or
modname
.
startswith
(
name
+
'.'
):
orig_modules
[
modname
]
=
sys
.
modules
[
modname
]
del
sys
.
modules
[
modname
]
def
_save_and_block_module
(
name
,
orig_modules
):
"""Helper function to save and block a module in sys.modules
...
...
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