| --- a/Lib/pydoc.py |
| +++ b/Lib/pydoc.py |
| @@ -272,6 +272,7 @@ |
| package path is specified, the module at the end of the path is returned, |
| not the package at the beginning. If the optional 'forceload' argument |
| is 1, we reload the module from disk (unless it's a dynamic extension).""" |
| + print('Trying a safeimport for', path, forceload, cache, file=sys.stderr) |
| try: |
| # If forceload is 1 and the module has been previously loaded from |
| # disk, we always have to reload the module. Checking the file's |
| @@ -290,20 +291,25 @@ |
| cache[key] = sys.modules[key] |
| del sys.modules[key] |
| module = __import__(path) |
| + print('WORKED', file=sys.stderr) |
| except: |
| # Did the error occur before or after the module was found? |
| (exc, value, tb) = info = sys.exc_info() |
| + print('*', value, path, value.name, file=sys.stderr) |
| if path in sys.modules: |
| # An error occurred while executing the imported module. |
| raise ErrorDuringImport(sys.modules[path].__file__, info) |
| elif exc is SyntaxError: |
| # A SyntaxError occurred before we could execute the module. |
| raise ErrorDuringImport(value.filename, info) |
| - elif exc is ImportError and extract_tb(tb)[-1][2]=='safeimport': |
| + #elif exc is ImportError and extract_tb(tb)[-1][2]=='safeimport': |
| + elif exc is ImportError and value.name == path.rpartition('.')[-1]: |
| # The import error occurred directly in this function, |
| # which means there is no such module in the path. |
| + print('***', value, path, value.name, file=sys.stderr) |
| return None |
| else: |
| + rint('**', value, path, value.name, file=sys.stderr) |
| # Some other error occurred during the importing process. |
| raise ErrorDuringImport(path, sys.exc_info()) |
| for part in path.split('.')[1:]: |