<s> import sys <EOL> import traceback <EOL> import logging <EOL> try : <EOL> from io import StringIO <EOL> except ImportError : <EOL> try : <EOL> from cStringIO import StringIO <EOL> except ImportError : <EOL> from StringIO import StringIO <EOL> if sys . version_info [ <NUM_LIT:0> ] < <NUM_LIT:3> : <EOL> def u ( strs ) : <EOL> return strs . decode ( '<STR_LIT:utf-8>' ) <EOL> else : <EOL> def u ( strs ) : <EOL> return strs <EOL> _tmp_stream = StringIO ( ) <EOL> def print_exc_plus ( stream = sys . stdout ) : <EOL> '''<STR_LIT>''' <EOL> write = stream . write <EOL> flush = stream . flush <EOL> tp , value , tb = sys . exc_info ( ) <EOL> while tb . tb_next : <EOL> tb = tb . tb_next <EOL> stack = list ( ) <EOL> f = tb . tb_frame <EOL> while f : <EOL> stack . append ( f ) <EOL> f = f . f_back <EOL> stack . reverse ( ) <EOL> try : <EOL> traceback . print_exc ( None , stream ) <EOL> except BaseException as e : <EOL> write ( u ( "<STR_LIT>" ) ) <EOL> write ( u ( str ( value ) ) ) <EOL> write ( u ( '<STR_LIT>' ) ) <EOL> finally : <EOL> flush ( ) <EOL> write ( u ( '<STR_LIT>' ) ) <EOL> for frame in stack : <EOL> write ( u ( '<STR_LIT>' % ( frame . f_code . co_name , <EOL> frame . f_code . co_filename , <EOL> frame . f_lineno ) ) ) <EOL> for key , value , in frame . f_locals . items ( ) : <EOL> write ( u ( '<STR_LIT>' % key ) ) <EOL> try : <EOL> write ( u ( '<STR_LIT>' % value ) ) <EOL> except : <EOL> write ( u ( '<STR_LIT>' ) ) <EOL> flush ( ) <EOL> def get_exc_plus ( ) : <EOL> _tmp_stream . seek ( <NUM_LIT:0> ) <EOL> _tmp_stream . truncate ( ) <EOL> print_exc_plus ( _tmp_stream ) <EOL> _tmp_stream . seek ( <NUM_LIT:0> ) <EOL> return _tmp_stream . read ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> def zero_error ( ) : <EOL> local_1 = range ( <NUM_LIT:5> ) <EOL> local_2 = '<STR_LIT>' <EOL> <NUM_LIT:1> / <NUM_LIT:0> <EOL> stream = StringIO ( ) <EOL> try : <EOL> zero_error ( ) <EOL> except Exception : <EOL> print_exc_plus ( stream ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( stream . getvalue ( ) ) <EOL> stream . close ( ) <EOL> try : <EOL> zero_error ( ) <EOL> except Exception : <EOL> print ( '<STR_LIT>' ) <EOL> print ( get_exc_plus ( ) ) </s>
