Defending against one possible flaw in original() which isn't currently a problem but may become so.
This commit is contained in:
@@ -151,6 +151,10 @@ def _original_patch_function(func, *module_names):
|
||||
def original(modname):
|
||||
""" This returns an unpatched version of a module; this is useful for
|
||||
Eventlet itself (i.e. tpool)."""
|
||||
# note that it's not necessary to temporarily install unpatched
|
||||
# versions of all patchable modules during the import of the
|
||||
# module; this is because none of them import each other, except
|
||||
# for threading which imports thread
|
||||
original_name = '__original_module_' + modname
|
||||
if original_name in sys.modules:
|
||||
return sys.modules.get(original_name)
|
||||
@@ -159,6 +163,11 @@ def original(modname):
|
||||
# dict; be sure to restore whatever module had that name already
|
||||
saver = SysModulesSaver((modname,))
|
||||
sys.modules.pop(modname, None)
|
||||
# install original thread module if we're getting the original
|
||||
# threading module
|
||||
if modname == 'threading':
|
||||
saver.save('thread')
|
||||
sys.modules['thread'] = original('thread')
|
||||
try:
|
||||
real_mod = __import__(modname, {}, {}, modname.split('.')[:-1])
|
||||
# hacky hack: Queue's constructor imports threading; therefore
|
||||
|
Reference in New Issue
Block a user