當前位置: 首頁>>代碼示例>>Python>>正文


Python __pypy__.tproxy方法代碼示例

本文整理匯總了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() 
開發者ID:leancloud,項目名稱:satori,代碼行數:25,代碼來源:_tblib.py

示例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) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:14,代碼來源:debug.py

示例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 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:10,代碼來源:debug.py

示例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 !") 
開發者ID:leancloud,項目名稱:satori,代碼行數:38,代碼來源:_tblib.py


注:本文中的__pypy__.tproxy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。