python类FrameType()的实例源码

sandbox.py 文件源码 项目:macos-st-packages 作者: zce 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def is_internal_attribute(obj, attr):
    """Test if the attribute given is an internal python attribute.  For
    example this function returns `True` for the `func_code` attribute of
    python objects.  This is useful if the environment method
    :meth:`~SandboxedEnvironment.is_safe_attribute` is overridden.

    >>> from jinja2.sandbox import is_internal_attribute
    >>> is_internal_attribute(str, "mro")
    True
    >>> is_internal_attribute(str, "upper")
    False
    """
    if isinstance(obj, types.FunctionType):
        if attr in UNSAFE_FUNCTION_ATTRIBUTES:
            return True
    elif isinstance(obj, types.MethodType):
        if attr in UNSAFE_FUNCTION_ATTRIBUTES or \
           attr in UNSAFE_METHOD_ATTRIBUTES:
            return True
    elif isinstance(obj, type):
        if attr == 'mro':
            return True
    elif isinstance(obj, (types.CodeType, types.TracebackType, types.FrameType)):
        return True
    elif isinstance(obj, types.GeneratorType):
        if attr in UNSAFE_GENERATOR_ATTRIBUTES:
            return True
    return attr.startswith('__')
inspect.py 文件源码 项目:MKFQ 作者: maojingios 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def getlineno(frame):
    """Get the line number from a frame object, allowing for optimization."""
    # FrameType.f_lineno is now a descriptor that grovels co_lnotab
    return frame.f_lineno
main.py 文件源码 项目:gopythongo 作者: gopythongo 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _sigint_handler(sig: int, frame: FrameType) -> None:
    print_warning("CTRL+BREAK. Exiting.")
    for k in break_handlers.keys():
        break_handlers[k]()
    sys.exit(1)
sandbox.py 文件源码 项目:RealtimePythonChat 作者: quangtqag 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def is_internal_attribute(obj, attr):
    """Test if the attribute given is an internal python attribute.  For
    example this function returns `True` for the `func_code` attribute of
    python objects.  This is useful if the environment method
    :meth:`~SandboxedEnvironment.is_safe_attribute` is overridden.

    >>> from jinja2.sandbox import is_internal_attribute
    >>> is_internal_attribute(str, "mro")
    True
    >>> is_internal_attribute(str, "upper")
    False
    """
    if isinstance(obj, types.FunctionType):
        if attr in UNSAFE_FUNCTION_ATTRIBUTES:
            return True
    elif isinstance(obj, types.MethodType):
        if attr in UNSAFE_FUNCTION_ATTRIBUTES or \
           attr in UNSAFE_METHOD_ATTRIBUTES:
            return True
    elif isinstance(obj, type):
        if attr == 'mro':
            return True
    elif isinstance(obj, (types.CodeType, types.TracebackType, types.FrameType)):
        return True
    elif isinstance(obj, types.GeneratorType):
        if attr in UNSAFE_GENERATOR_ATTRIBUTES:
            return True
    elif hasattr(types, 'CoroutineType') and isinstance(obj, types.CoroutineType):
        if attr in UNSAFE_COROUTINE_ATTRIBUTES:
            return True
    elif hasattr(types, 'AsyncGeneratorType') and isinstance(obj, types.AsyncGeneratorType):
        if attr in UNSAFE_ASYNC_GENERATOR_ATTRIBUTES:
            return True
    return attr.startswith('__')
sandbox.py 文件源码 项目:Indushell 作者: SecarmaLabs 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def is_internal_attribute(obj, attr):
    """Test if the attribute given is an internal python attribute.  For
    example this function returns `True` for the `func_code` attribute of
    python objects.  This is useful if the environment method
    :meth:`~SandboxedEnvironment.is_safe_attribute` is overridden.

    >>> from jinja2.sandbox import is_internal_attribute
    >>> is_internal_attribute(str, "mro")
    True
    >>> is_internal_attribute(str, "upper")
    False
    """
    if isinstance(obj, types.FunctionType):
        if attr in UNSAFE_FUNCTION_ATTRIBUTES:
            return True
    elif isinstance(obj, types.MethodType):
        if attr in UNSAFE_FUNCTION_ATTRIBUTES or \
           attr in UNSAFE_METHOD_ATTRIBUTES:
            return True
    elif isinstance(obj, type):
        if attr == 'mro':
            return True
    elif isinstance(obj, (types.CodeType, types.TracebackType, types.FrameType)):
        return True
    elif isinstance(obj, types.GeneratorType):
        if attr in UNSAFE_GENERATOR_ATTRIBUTES:
            return True
    elif hasattr(types, 'CoroutineType') and isinstance(obj, types.CoroutineType):
        if attr in UNSAFE_COROUTINE_ATTRIBUTES:
            return True
    elif hasattr(types, 'AsyncGeneratorType') and isinstance(obj, types.AsyncGeneratorType):
        if attr in UNSAFE_ASYNC_GENERATOR_ATTRIBUTES:
            return True
    return attr.startswith('__')
test_tracing.py 文件源码 项目:MonkeyType 作者: Instagram 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def has_optional_kwarg(a: int, b: str = None) -> Optional[FrameType]:
    return inspect.currentframe()
test_tracing.py 文件源码 项目:MonkeyType 作者: Instagram 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def has_locals(foo: str) -> Optional[FrameType]:
        bar = 'baz'  # noqa - Needed to ensure non-argument locals are present in the returned frame
        return inspect.currentframe()
test_tracing.py 文件源码 项目:MonkeyType 作者: Instagram 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def a_static_method() -> Optional[FrameType]:
        return inspect.currentframe()
test_tracing.py 文件源码 项目:MonkeyType 作者: Instagram 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def a_class_method(cls) -> Optional[FrameType]:
        return inspect.currentframe()
test_tracing.py 文件源码 项目:MonkeyType 作者: Instagram 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def an_instance_method(self) -> Optional[FrameType]:
        return inspect.currentframe()
test_tracing.py 文件源码 项目:MonkeyType 作者: Instagram 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def a_module_function() -> Optional[FrameType]:
    return inspect.currentframe()
util.py 文件源码 项目:MonkeyType 作者: Instagram 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def a_static_method(foo: Any) -> Optional[FrameType]:
        return inspect.currentframe()
util.py 文件源码 项目:MonkeyType 作者: Instagram 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def a_class_method(cls, foo: Any) -> Optional[FrameType]:
        return inspect.currentframe()
util.py 文件源码 项目:MonkeyType 作者: Instagram 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def an_instance_method(self, foo: Any, bar: Any) -> Optional[FrameType]:
        return inspect.currentframe()
util.py 文件源码 项目:MonkeyType 作者: Instagram 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def a_property(self) -> Optional[FrameType]:
        return inspect.currentframe()
util.py 文件源码 项目:MonkeyType 作者: Instagram 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def a_settable_property(self, unused) -> Optional[FrameType]:
        return inspect.currentframe()
sandbox.py 文件源码 项目:Liljimbo-Chatbot 作者: chrisjim316 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def is_internal_attribute(obj, attr):
    """Test if the attribute given is an internal python attribute.  For
    example this function returns `True` for the `func_code` attribute of
    python objects.  This is useful if the environment method
    :meth:`~SandboxedEnvironment.is_safe_attribute` is overridden.

    >>> from jinja2.sandbox import is_internal_attribute
    >>> is_internal_attribute(str, "mro")
    True
    >>> is_internal_attribute(str, "upper")
    False
    """
    if isinstance(obj, types.FunctionType):
        if attr in UNSAFE_FUNCTION_ATTRIBUTES:
            return True
    elif isinstance(obj, types.MethodType):
        if attr in UNSAFE_FUNCTION_ATTRIBUTES or \
           attr in UNSAFE_METHOD_ATTRIBUTES:
            return True
    elif isinstance(obj, type):
        if attr == 'mro':
            return True
    elif isinstance(obj, (types.CodeType, types.TracebackType, types.FrameType)):
        return True
    elif isinstance(obj, types.GeneratorType):
        if attr in UNSAFE_GENERATOR_ATTRIBUTES:
            return True
    elif hasattr(types, 'CoroutineType') and isinstance(obj, types.CoroutineType):
        if attr in UNSAFE_COROUTINE_ATTRIBUTES:
            return True
    elif hasattr(types, 'AsyncGeneratorType') and isinstance(obj, types.AsyncGeneratorType):
        if attr in UNSAFE_ASYNC_GENERATOR_ATTRIBUTES:
            return True
    return attr.startswith('__')
sandbox.py 文件源码 项目:flask_system 作者: prashasy 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def is_internal_attribute(obj, attr):
    """Test if the attribute given is an internal python attribute.  For
    example this function returns `True` for the `func_code` attribute of
    python objects.  This is useful if the environment method
    :meth:`~SandboxedEnvironment.is_safe_attribute` is overridden.

    >>> from jinja2.sandbox import is_internal_attribute
    >>> is_internal_attribute(str, "mro")
    True
    >>> is_internal_attribute(str, "upper")
    False
    """
    if isinstance(obj, types.FunctionType):
        if attr in UNSAFE_FUNCTION_ATTRIBUTES:
            return True
    elif isinstance(obj, types.MethodType):
        if attr in UNSAFE_FUNCTION_ATTRIBUTES or \
           attr in UNSAFE_METHOD_ATTRIBUTES:
            return True
    elif isinstance(obj, type):
        if attr == 'mro':
            return True
    elif isinstance(obj, (types.CodeType, types.TracebackType, types.FrameType)):
        return True
    elif isinstance(obj, types.GeneratorType):
        if attr in UNSAFE_GENERATOR_ATTRIBUTES:
            return True
    elif hasattr(types, 'CoroutineType') and isinstance(obj, types.CoroutineType):
        if attr in UNSAFE_COROUTINE_ATTRIBUTES:
            return True
    elif hasattr(types, 'AsyncGeneratorType') and isinstance(obj, types.AsyncGeneratorType):
        if attr in UNSAFE_ASYNC_GENERATOR_ATTRIBUTES:
            return True
    return attr.startswith('__')
inspect.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def isframe(object):
    """Return true if the object is a frame object.

    Frame objects provide these attributes:
        f_back          next outer frame object (this frame's caller)
        f_builtins      built-in namespace seen by this frame
        f_code          code object being executed in this frame
        f_globals       global namespace seen by this frame
        f_lasti         index of last attempted instruction in bytecode
        f_lineno        current line number in Python source code
        f_locals        local namespace seen by this frame
        f_trace         tracing function for this frame, or None"""
    return isinstance(object, types.FrameType)
inspect.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def getlineno(frame):
    """Get the line number from a frame object, allowing for optimization."""
    # FrameType.f_lineno is now a descriptor that grovels co_lnotab
    return frame.f_lineno


问题


面经


文章

微信
公众号

扫码关注公众号