Commit ba4ece9a authored by Shane Hathaway's avatar Shane Hathaway

When converting Unauthorized to ImportError, include the Unauthorized error

in the error value.  It may provide extra info.
parent 5470157e
......@@ -11,7 +11,7 @@
#
##############################################################################
__version__='$Revision: 1.11 $'[11:-2]
__version__='$Revision: 1.12 $'[11:-2]
from RestrictedPython.Guards import safe_builtins, _full_read_guard, \
full_write_guard
......@@ -145,9 +145,9 @@ def guarded_import(mname, globals={}, locals={}, fromlist=None):
raise Unauthorized
else:
return __import__(mname, globals, locals, fromlist)
except Unauthorized:
raise ImportError, ('import of "%s" from "%s" is unauthorized'
% (name, mname))
except Unauthorized, why:
raise ImportError, ('import of "%s" from "%s" is unauthorized. %s'
% (name, mname, why))
raise ImportError, 'import of "%s" is unauthorized' % mname
safe_builtins['__import__'] = guarded_import
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment