

def _generate_init(class_, class_manager):
    'Build an __init__ decorator that triggers ClassManager events.'
    original__init__ = class_.__init__
    assert original__init__
    func_body = 'def __init__(%(apply_pos)s):\n    new_state = class_manager._new_state_if_none(%(self_arg)s)\n    if new_state:\n        return new_state._initialize_instance(%(apply_kw)s)\n    else:\n        return original__init__(%(apply_kw)s)\n'
    func_vars = util.format_argspec_init(original__init__, grouped=False)
    func_text = (func_body % func_vars)
    if util.py2k:
        func = getattr(original__init__, 'im_func', original__init__)
        func_defaults = getattr(func, 'func_defaults', None)
    else:
        func_defaults = getattr(original__init__, '__defaults__', None)
        func_kw_defaults = getattr(original__init__, '__kwdefaults__', None)
    env = locals().copy()
    exec(func_text, env)
    __init__ = env['__init__']
    __init__.__doc__ = original__init__.__doc__
    if func_defaults:
        func_vars.__defaults__ = func_defaults
    if ((not util.py2k) and func_kw_defaults):
        __init__.__kwdefaults__ = func_kw_defaults
    return __init__

dataset/ETHPy150Open RoseOu/flasky/venv/lib/python2.7/site-packages/sqlalchemy/orm/instrumentation.py _generate_init/VarMisuse@142/319 `__init__`->`func_vars`