<s> import py , sys <EOL> class DeprecationWarning ( DeprecationWarning ) : <EOL> def __init__ ( self , msg , path , lineno ) : <EOL> self . msg = msg <EOL> self . path = path <EOL> self . lineno = lineno <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . path , self . lineno + <NUM_LIT:1> , self . msg ) <EOL> def __str__ ( self ) : <EOL> return self . msg <EOL> def _apiwarn ( startversion , msg , stacklevel = <NUM_LIT:2> , function = None ) : <EOL> if isinstance ( stacklevel , str ) : <EOL> frame = sys . _getframe ( <NUM_LIT:1> ) <EOL> level = <NUM_LIT:1> <EOL> found = frame . f_code . co_filename . find ( stacklevel ) != - <NUM_LIT:1> <EOL> while frame : <EOL> co = frame . f_code <EOL> if co . co_filename . find ( stacklevel ) == - <NUM_LIT:1> : <EOL> if found : <EOL> stacklevel = level <EOL> break <EOL> else : <EOL> found = True <EOL> level += <NUM_LIT:1> <EOL> frame = frame . f_back <EOL> else : <EOL> stacklevel = <NUM_LIT:1> <EOL> msg = "<STR_LIT>" % ( msg , startversion ) <EOL> warn ( msg , stacklevel = stacklevel + <NUM_LIT:1> , function = function ) <EOL> def warn ( msg , stacklevel = <NUM_LIT:1> , function = None ) : <EOL> if function is not None : <EOL> filename = py . std . inspect . getfile ( function ) <EOL> lineno = py . code . getrawcode ( function ) . co_firstlineno <EOL> else : <EOL> try : <EOL> caller = sys . _getframe ( stacklevel ) <EOL> except ValueError : <EOL> globals = sys . __dict__ <EOL> lineno = <NUM_LIT:1> <EOL> else : <EOL> globals = caller . f_globals <EOL> lineno = caller . f_lineno <EOL> if '<STR_LIT>' in globals : <EOL> module = globals [ '<STR_LIT>' ] <EOL> else : <EOL> module = "<STR_LIT>" <EOL> filename = globals . get ( '<STR_LIT>' ) <EOL> if filename : <EOL> fnl = filename . lower ( ) <EOL> if fnl . endswith ( "<STR_LIT>" ) or fnl . endswith ( "<STR_LIT>" ) : <EOL> filename = filename [ : - <NUM_LIT:1> ] <EOL> elif fnl . endswith ( "<STR_LIT>" ) : <EOL> filename = filename . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> else : <EOL> if module == "<STR_LIT:__main__>" : <EOL> try : <EOL> filename = sys . argv [ <NUM_LIT:0> ] <EOL> except AttributeError : <EOL> filename = '<STR_LIT:__main__>' <EOL> if not filename : <EOL> filename = module <EOL> path = py . path . local ( filename ) <EOL> warning = DeprecationWarning ( msg , path , lineno ) <EOL> py . std . warnings . warn_explicit ( warning , category = Warning , <EOL> filename = str ( warning . path ) , <EOL> lineno = warning . lineno , <EOL> registry = py . std . warnings . __dict__ . setdefault ( <EOL> "<STR_LIT>" , { } ) <EOL> ) </s>
