mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 19:52:54 +01:00
Fixed fix in the interpreter.
This commit is contained in:
parent
740a57d78a
commit
445e76bef7
16
src/fix.py
16
src/fix.py
@ -199,12 +199,18 @@ 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__'):
|
||||||
|
Exception._original__init__ = Exception.__init__
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
caller = sys._getframe(1)
|
# We had sys._getframe(1) here for awhile, but in the interactive
|
||||||
module = sys.modules.get(caller.f_globals.get('__name__'))
|
# interpreter, there isn't enough call stack. Thanks, Rafterman, for
|
||||||
self.__revision__ = getattr(module, '__revision__', None)
|
# pointing that out.
|
||||||
Exception__init__(self, *args, **kwargs)
|
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__
|
Exception.__init__ = __init__
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user