Commit 5dc9c791 authored by Kirill Smelkov's avatar Kirill Smelkov

X wcfs: Kill xdefer

It has been properly implemented in pygolang:

pygolang@bb9a94c3
parent d75b2304
......@@ -254,7 +254,7 @@ setup(
# specify either to use e.g. ZODB3.10 or ZODB4 )
'ZODB3 >= 3.10',
'pygolang >= 0.0.2', # defer, sync.WaitGroup, ...
'pygolang >= 0.0.5', # defer, sync.WaitGroup, ...
'six', # compat py2/py3
......
......@@ -1968,36 +1968,3 @@ def is_mountpoint(path): # -> bool
# eprint prints msg to stderr
def eprint(msg):
print(msg, file=sys.stderr)
# xdefer is like defer, but makes sure exception raised before deferred
# function is called is not lost.
#
# if deferred function raises exception itself - it prints previous exception to stderr.
#
# XXX xdefer is workaround for Python2 not having exception chaining (PEP 3134)
# without which, if e.g. tDB.close() raises exception, it prevents to see
# whether and which an assert in the test failed.
#
# XXX merge into defer?
_defer = defer # original golang.defer
def xdefer(f):
# hack - imitate as if defer called from under xdefer was called directly by caller func
fgo = inspect.currentframe().f_back.f_back
__goframe__ = fgo.f_locals['__goframe__']
_xdefer(f)
def _xdefer(f):
def _():
# call f, but print previous exception if f raises
exc_type, exc_value, exc_traceback = sys.exc_info()
try:
f()
except:
if exc_type is not None:
traceback.print_exception(exc_type, exc_value, exc_traceback)
raise
_defer(_)
# replace defer with xdefer
defer = xdefer
del xdefer
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