def is_internal_attribute(obj, attr):
 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('__')

def is_internal_attribute ( obj , attr ) : 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 if the attribute given is an internal python attribute .