Skip to content

Commit feb9fdd

Browse files
committed
More updates to future.standard_library: disable all scrubbing of sys.modules cache
1 parent e59d4f7 commit feb9fdd

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

future/standard_library/__init__.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,16 @@
9393
# test
9494
# email
9595

96-
REPLACED_MODULES = set(['test', 'urllib', 'pickle']) # add email and dbm when we support it
96+
REPLACED_MODULES = set(['test', 'urllib', 'pickle', 'dbm']) # add email and dbm when we support it
9797

9898
# The following module names are not present in Python 2.x, so they cause no
99-
# potential clashes:
99+
# potential clashes between the old and new names:
100100
# http
101101
# html
102102
# tkinter
103103
# xmlrpc
104-
105-
# These modules need names from elsewhere being added to them:
106-
# subprocess: should provide getoutput and other fns from commands
107-
# module but these fns are missing: getstatus, mk2arg,
108-
# mkarg
109-
# re: needs an ASCII constant that works compatibly with Py3
110-
111-
112-
# Old to new
113-
# etc: see lib2to3/fixes/fix_imports.py
104+
# Keys: Py2 / real module names
105+
# Values: Py3 / simulated module names
114106
RENAMES = {
115107
# 'cStringIO': 'io', # there's a new io module in Python 2.6
116108
# that provides StringIO and BytesIO
@@ -182,6 +174,14 @@
182174

183175

184176
# Harmless renames that we can insert.
177+
# These modules need names from elsewhere being added to them:
178+
# subprocess: should provide getoutput and other fns from commands
179+
# module but these fns are missing: getstatus, mk2arg,
180+
# mkarg
181+
# re: needs an ASCII constant that works compatibly with Py3
182+
183+
# etc: see lib2to3/fixes/fix_imports.py
184+
185185
# (New module name, new object name, old module name, old object name)
186186
MOVES = [('collections', 'UserList', 'UserList', 'UserList'),
187187
('collections', 'UserDict', 'UserDict', 'UserDict'),
@@ -323,16 +323,16 @@ def __enter__(self):
323323
# flog.debug('Entering hooks context manager')
324324
self.old_sys_modules = copy.copy(sys.modules)
325325
self.hooks_were_installed = detect_hooks()
326-
self.scrubbed = scrub_py2_sys_modules()
326+
# self.scrubbed = scrub_py2_sys_modules()
327327
install_hooks()
328328
return self
329329

330330
def __exit__(self, *args):
331331
# flog.debug('Exiting hooks context manager')
332-
restore_sys_modules(self.scrubbed)
332+
# restore_sys_modules(self.scrubbed)
333333
if not self.hooks_were_installed:
334334
remove_hooks()
335-
scrub_future_sys_modules()
335+
# scrub_future_sys_modules()
336336

337337
# Sanity check for is_py2_stdlib_module(): We aren't replacing any
338338
# builtin modules names:
@@ -418,14 +418,13 @@ class suspend_hooks(object):
418418
def __enter__(self):
419419
self.hooks_were_installed = detect_hooks()
420420
remove_hooks()
421-
self.scrubbed = scrub_future_sys_modules()
421+
# self.scrubbed = scrub_future_sys_modules()
422422
return self
423423

424424
def __exit__(self, *args):
425425
if self.hooks_were_installed:
426-
# scrub_py2_sys_modules() # in case they interfere ... e.g. urllib
427426
install_hooks()
428-
restore_sys_modules(self.scrubbed)
427+
# restore_sys_modules(self.scrubbed)
429428

430429

431430
def restore_sys_modules(scrubbed):
@@ -547,7 +546,7 @@ def enable_hooks():
547546
install_hooks()
548547

549548

550-
def remove_hooks(scrub_sys_modules=True):
549+
def remove_hooks(scrub_sys_modules=False):
551550
"""
552551
This function removes the import hook from sys.meta_path.
553552
"""

0 commit comments

Comments
 (0)