本文整理汇总了Python中__pypy__.tproxy方法的典型用法代码示例。如果您正苦于以下问题:Python __pypy__.tproxy方法的具体用法?Python __pypy__.tproxy怎么用?Python __pypy__.tproxy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类__pypy__
的用法示例。
在下文中一共展示了__pypy__.tproxy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _init
# 需要导入模块: import __pypy__ [as 别名]
# 或者: from __pypy__ import tproxy [as 别名]
def _init():
global _installed
global tb_set_next
if _installed:
return
_installed = True
import platform
try:
if platform.python_implementation() == 'CPython':
tb_set_next = _init_ugly_crap()
except Exception as exc:
sys.stderr.write("Failed to initialize cpython support: {!r}".format(exc))
try:
from __pypy__ import tproxy
except ImportError:
tproxy = None
if not tb_set_next and not tproxy:
raise ImportError("Cannot use tblib. Runtime not supported.")
_import_dump_load()
install()
示例2: make_frame_proxy
# 需要导入模块: import __pypy__ [as 别名]
# 或者: from __pypy__ import tproxy [as 别名]
def make_frame_proxy(frame):
proxy = TracebackFrameProxy(frame)
if tproxy is None:
return proxy
def operation_handler(operation, *args, **kwargs):
if operation in ('__getattribute__', '__getattr__'):
return getattr(proxy, args[0])
elif operation == '__setattr__':
proxy.__setattr__(*args, **kwargs)
else:
return getattr(proxy, operation)(*args, **kwargs)
return tproxy(TracebackType, operation_handler)
示例3: standard_exc_info
# 需要导入模块: import __pypy__ [as 别名]
# 或者: from __pypy__ import tproxy [as 别名]
def standard_exc_info(self):
"""Standard python exc_info for re-raising"""
tb = self.frames[0]
# the frame will be an actual traceback (or transparent proxy) if
# we are on pypy or a python implementation with support for tproxy
if type(tb) is not TracebackType:
tb = tb.tb
return self.exc_type, self.exc_value, tb
示例4: as_traceback
# 需要导入模块: import __pypy__ [as 别名]
# 或者: from __pypy__ import tproxy [as 别名]
def as_traceback(self):
if tproxy:
return tproxy(TracebackType, self.__tproxy_handler)
elif tb_set_next:
f_code = self.tb_frame.f_code
code = compile('\n' * (self.tb_lineno - 1) + 'raise __traceback_maker', self.tb_frame.f_code.co_filename, 'exec')
if PY3:
code = CodeType(
0, 0,
f_code.co_nlocals, f_code.co_stacksize, f_code.co_flags,
code.co_code, code.co_consts, code.co_names, code.co_varnames,
f_code.co_filename, f_code.co_name,
code.co_firstlineno, b"",
(), ()
)
else:
code = CodeType(
0,
f_code.co_nlocals, f_code.co_stacksize, f_code.co_flags,
code.co_code, code.co_consts, code.co_names, code.co_varnames,
f_code.co_filename.encode(), f_code.co_name.encode(),
code.co_firstlineno, b"",
(), ()
)
try:
exec(code, self.tb_frame.f_globals, {})
except:
tb = sys.exc_info()[2].tb_next
tb_set_next(tb, self.tb_next and self.tb_next.as_traceback())
try:
return tb
finally:
del tb
else:
raise RuntimeError("Cannot re-create traceback !")