Fixed fix in the interpreter.

This commit is contained in:
Jeremy Fincher 2004-09-01 12:33:22 +00:00
parent 740a57d78a
commit 445e76bef7

View File

@ -199,13 +199,19 @@ if not hasattr(socket, 'sslerror'):
socket.sslerror = socket.error socket.sslerror = socket.error
# Trick to get an __revision__ attribute in all exceptions, if possible. # Trick to get an __revision__ attribute in all exceptions, if possible.
Exception__init__ = Exception.__init__ if not hasattr(Exception, '_original__init__'):
def __init__(self, *args, **kwargs): Exception._original__init__ = Exception.__init__
caller = sys._getframe(1) def __init__(self, *args, **kwargs):
module = sys.modules.get(caller.f_globals.get('__name__')) # We had sys._getframe(1) here for awhile, but in the interactive
self.__revision__ = getattr(module, '__revision__', None) # interpreter, there isn't enough call stack. Thanks, Rafterman, for
Exception__init__(self, *args, **kwargs) # pointing that out.
Exception.__init__ = __init__ me = sys._getframe(0)
caller = me.f_back
callerGlobals = getattr(caller, 'f_globals', {})
callerModule = sys.modules.get(callerGlobals.get('__name__'))
self.__revision__ = getattr(callerModule, '__revision__', None)
self._original__init__(*args, **kwargs)
Exception.__init__ = __init__
for name in exported: for name in exported: