Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(458)

Unified Diff: Lib/pydoc.py

Issue 1559549: ImportError needs attributes for module and file name
Patch Set: Created 1 year, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Include/pyerrors.h ('k') | Lib/test/test_import.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- 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:]:
« no previous file with comments | « Include/pyerrors.h ('k') | Lib/test/test_import.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7