<s> from __future__ import absolute_import <EOL> import sys , functools , inspect <EOL> def return_locals ( func ) : <EOL> '''<STR_LIT>''' <EOL> @ functools . wraps ( func ) <EOL> def wrap ( * args , ** kwargs ) : <EOL> frames = [ ] <EOL> def tracer ( frame , event , arg ) : <EOL> frames . append ( frame ) <EOL> sys . settrace ( old_tracer ) <EOL> if old_tracer is not None : <EOL> return old_tracer ( frame , event , arg ) <EOL> old_tracer = sys . gettrace ( ) <EOL> sys . settrace ( tracer ) <EOL> try : <EOL> func ( * args , ** kwargs ) <EOL> finally : <EOL> sys . settrace ( old_tracer ) <EOL> assert len ( frames ) == <NUM_LIT:1> <EOL> argspec = inspect . getargspec ( func ) <EOL> argnames = list ( argspec . args ) <EOL> if argspec . varargs is not None : <EOL> argnames . append ( argspec . varargs ) <EOL> if argspec . keywords is not None : <EOL> argnames . append ( argspec . keywords ) <EOL> return { name : value for name , value in frames . pop ( <NUM_LIT:0> ) . f_locals . items ( ) <EOL> if name not in argnames } <EOL> return wrap </s>
