@@ -262,7 +262,8 @@ def _find_and_load_module(self, name, path=None):
262262 try :
263263 path = package .__path__
264264 except AttributeError :
265- logging .warn ('Debug me: no __path__. What to do?' )
265+ logging .debug ('Debug me: no __path__. '
266+ 'Should anything special be done here?' )
266267 pass
267268 # if packagename == 'future':
268269 # path = FIXME
@@ -360,15 +361,15 @@ class hooks(object):
360361 imported modules (like requests).
361362 """
362363 def __enter__ (self ):
363- # print ('Entering CM ')
364+ logging . debug ('Entering hooks context manager ' )
364365 self .old_sys_modules = copy .copy (sys .modules )
365366 self .hooks_were_installed = detect_hooks ()
366367 scrub_py2_stdlib_modules ()
367368 install_hooks ()
368369 return self
369370
370371 def __exit__ (self , * args ):
371- # print ('Exiting CM ')
372+ logging . debug ('Exiting hooks context manager ' )
372373 if not self .hooks_were_installed :
373374 # Reset sys.modules to how it was at the start.
374375 sys .modules = self .old_sys_modules
@@ -383,11 +384,10 @@ def scrub_py2_stdlib_modules():
383384 (e.g. urllib) despite the import hooks.
384385 """
385386 CLASH_MODULE_NAMES = ['urllib' , 'test' ]
386- future_stdlib = os .path .join ('future' , 'standard_library' )
387387 for modulename , module in sys .modules .items ():
388388 for clasher in CLASH_MODULE_NAMES :
389389 if modulename .startswith (clasher ):
390- logging .warn ('Deleting {} from sys.modules' .format (modulename ))
390+ logging .debug ('Deleting {} from sys.modules' .format (modulename ))
391391 del sys .modules [modulename ]
392392
393393
@@ -400,7 +400,7 @@ def scrub_future_stdlib_modules():
400400 if modulename not in ['standard_library' , 'future.standard_library' ]:
401401 if (hasattr (module , '__file__' ) and
402402 module .__file__ .startswith (future_stdlib )):
403- logging .warn ('Deleting {} from sys.modules' .format (modulename ))
403+ logging .debug ('Deleting {} from sys.modules' .format (modulename ))
404404 del sys .modules [modulename ]
405405
406406
@@ -430,8 +430,8 @@ def __exit__(self, *args):
430430def install_hooks ():
431431 if utils .PY3 :
432432 return
433- # print ('sys.meta_path was: {}'.format(sys.meta_path))
434- # print ('Installing hooks ...')
433+ logging . debug ('sys.meta_path was: {}' .format (sys .meta_path ))
434+ logging . debug ('Installing hooks ...' )
435435
436436 for (newmodname , newobjname , oldmodname , oldobjname ) in MOVES :
437437 newmod = __import__ (newmodname )
@@ -443,7 +443,7 @@ def install_hooks():
443443 newhook = RenameImport (RENAMES )
444444 if not detect_hooks ():
445445 sys .meta_path .append (newhook )
446- # print ('sys.meta_path is now: {}'.format(sys.meta_path))
446+ logging . debug ('sys.meta_path is now: {}' .format (sys .meta_path ))
447447
448448
449449def enable_hooks ():
@@ -460,7 +460,7 @@ def remove_hooks():
460460 """
461461 if utils .PY3 :
462462 return
463- # print ('Uninstalling hooks ...')
463+ logging . debug ('Uninstalling hooks ...' )
464464 # Loop backwards, so deleting items keeps the ordering:
465465 for i , hook in list (enumerate (sys .meta_path ))[::- 1 ]:
466466 if hasattr (hook , 'RENAMER' ):
@@ -479,12 +479,12 @@ def detect_hooks():
479479 """
480480 Returns True if the import hooks are installed, False if not.
481481 """
482- # print ('Detecting hooks ...')
482+ logging . debug ('Detecting hooks ...' )
483483 present = any ([hasattr (hook , 'RENAMER' ) for hook in sys .meta_path ])
484- # if present:
485- # print ('Detected.')
486- # else:
487- # print ('Not detected.')
484+ if present :
485+ logging . debug ('Detected.' )
486+ else :
487+ logging . debug ('Not detected.' )
488488 return present
489489
490490
0 commit comments