@@ -397,75 +397,9 @@ def scrub_py2_sys_modules():
397397
398398def scrub_future_sys_modules ():
399399 """
400- On Py2 only: Removes any modules such as ``http`` and ``html.parser`` from
401- the ``sys.modules`` cache. Such modules would confuse code such as this::
402-
403- # PyChecker does something like this:
404- try:
405- import builtins
406- except:
407- PY3 = False
408- finally:
409- PY3 = True
410-
411- or this::
412-
413- import urllib # We want this to pull in only the Py2 module
414- # after scrub_future_sys_modules() has been called
415-
416- or this::
417-
418- # Requests does this in requests/packages/urllib3/connection.py:
419- try: # Python 3
420- from http.client import HTTPConnection, HTTPException
421- except ImportError:
422- from httplib import HTTPConnection, HTTPException
423-
424- This function removes items matching this spec from sys.modules::
425-
426- key: new_py3_module_name
427- value: either future.backports module or py2 module with
428- another name
400+ Deprecated.
429401 """
430- scrubbed = {}
431- if PY3 :
432- return {}
433- for modulename , module in sys .modules .items ():
434- if modulename .startswith ('future' ):
435- flog .debug ('Not removing %s' % modulename )
436- continue
437- # We don't want to remove Python 2.x urllib if this is cached.
438- # But we do want to remove modules under their new names, e.g.
439- # 'builtins'.
440-
441- # We look for builtins, configparser, urllib, email, http, etc., and
442- # their submodules
443- if (modulename in RENAMES .values () or
444- any (modulename .startswith (m + '.' ) for m in RENAMES .values ()) or
445- 'urllib' in modulename ):
446-
447- if module is None :
448- # This happens for e.g. __future__ imports. Delete it.
449- flog .debug ('Deleting empty module {0} from sys.modules'
450- .format (modulename ))
451- del sys .modules [modulename ]
452- continue
453-
454- # Not all modules come from future.moves. Example:
455- # sys.modules['builtins'] == <module '__builtin__' (built-in)>
456- p = os .path .join ('future' , 'moves' , modulename .replace ('.' , os .sep ))
457- # six.moves doesn't have a __file__ attribute:
458- if (hasattr (module , '__file__' ) and p in module .__file__ or
459- hasattr (module , '__future_module__' )):
460- flog .debug ('Deleting (future) {0} {1} from sys.modules'
461- .format (modulename , module ))
462- scrubbed [modulename ] = sys .modules [modulename ]
463- del sys .modules [modulename ]
464- else :
465- flog .debug ('Not deleting {0} {1} from sys.modules'
466- .format (modulename , module ))
467- return scrubbed
468-
402+ return {}
469403
470404class suspend_hooks (object ):
471405 """
0 commit comments