(x)
Helper to handle methods, compiled or raw code objects, and strings.
Helper to handle methods, compiled or raw code objects, and strings.
Helper to handle methods compiled or raw code objects and strings .
def _get_code_object(x):
    """Helper to handle methods, compiled or raw code objects, and strings."""
    # Extract functions from methods.
    if hasattr(x, '__func__'):
        x = x.__func__
    # Extract compiled code objects from...
    if hasattr(x, '__code__'):  # ...a function, or
        x = x.__code__
    elif hasattr(x, 'gi_code'):  #...a generator object, or
        x = x.gi_code
    elif hasattr(x, 'ag_code'):  #...an asynchronous generator object, or
        x = x.ag_code
    elif hasattr(x, 'cr_code'):  #...a coroutine.
        x = x.cr_code
    # Handle source code.
    if isinstance(x, str):
        x = _try_compile(x, "<disassembly>")
    # By now, if we don't have a code object, we can't disassemble x.
    if hasattr(x, 'co_code'):
        return x
    raise TypeError("don't know how to disassemble %s objects" %
                    type(x).__name__)
def _get_code_object ( x ) : # Extract functions from methods. if hasattr ( x , '__func__' ) : x = x . __func__ # Extract compiled code objects from... if hasattr ( x , '__code__' ) : # ...a function, or x = x . __code__ elif hasattr ( x , 'gi_code' ) : #...a generator object, or x = x . gi_code elif hasattr ( x , 'ag_code' ) : #...an asynchronous generator object, or x = x . ag_code elif hasattr ( x , 'cr_code' ) : #...a coroutine. x = x . cr_code # Handle source code. if isinstance ( x , str ) : x = _try_compile ( x , "<disassembly>" ) # By now, if we don't have a code object, we can't disassemble x. if hasattr ( x , 'co_code' ) : return x raise TypeError ( "don't know how to disassemble %s objects" % type ( x ) . __name__ )