<s> """<STR_LIT>""" <EOL> from pypy . interpreter import gateway , buffer <EOL> from pypy . interpreter . baseobjspace import ObjSpace <EOL> from pypy . interpreter . error import OperationError <EOL> from pypy . rlib . runicode import UNICHR <EOL> import __builtin__ <EOL> NoneNotWrapped = gateway . NoneNotWrapped <EOL> Buffer = buffer . Buffer <EOL> def abs ( space , w_val ) : <EOL> "<STR_LIT>" <EOL> return space . abs ( w_val ) <EOL> def chr ( space , w_ascii ) : <EOL> "<STR_LIT>" <EOL> try : <EOL> char = __builtin__ . chr ( space . int_w ( w_ascii ) ) <EOL> except ValueError : <EOL> raise OperationError ( space . w_ValueError , <EOL> space . wrap ( "<STR_LIT>" ) ) <EOL> return space . wrap ( char ) <EOL> def unichr ( space , code ) : <EOL> "<STR_LIT>" <EOL> try : <EOL> c = UNICHR ( code ) <EOL> except ValueError : <EOL> raise OperationError ( space . w_ValueError , <EOL> space . wrap ( "<STR_LIT>" ) ) <EOL> return space . wrap ( c ) <EOL> unichr . unwrap_spec = [ ObjSpace , int ] <EOL> def len ( space , w_obj ) : <EOL> "<STR_LIT>" <EOL> return space . len ( w_obj ) <EOL> def checkattrname ( space , w_name ) : <EOL> if not space . is_true ( space . is_ ( w_name , space . w_str ) ) : <EOL> name = space . str_w ( w_name ) <EOL> w_name = space . wrap ( name ) <EOL> return w_name <EOL> def delattr ( space , w_object , w_name ) : <EOL> """<STR_LIT>""" <EOL> w_name = checkattrname ( space , w_name ) <EOL> space . delattr ( w_object , w_name ) <EOL> return space . w_None <EOL> def getattr ( space , w_object , w_name , w_defvalue = NoneNotWrapped ) : <EOL> """<STR_LIT>""" <EOL> w_name = checkattrname ( space , w_name ) <EOL> try : <EOL> return space . getattr ( w_object , w_name ) <EOL> except OperationError , e : <EOL> if w_defvalue is not None : <EOL> if e . match ( space , space . w_AttributeError ) : <EOL> return w_defvalue <EOL> raise <EOL> def hasattr ( space , w_object , w_name ) : <EOL> """<STR_LIT>""" <EOL> w_name = checkattrname ( space , w_name ) <EOL> if space . findattr ( w_object , w_name ) is not None : <EOL> return space . w_True <EOL> else : <EOL> return space . w_False <EOL> def hash ( space , w_object ) : <EOL> """<STR_LIT>""" <EOL> return space . hash ( w_object ) <EOL> def oct ( space , w_val ) : <EOL> """<STR_LIT>""" <EOL> return space . oct ( w_val ) <EOL> def hex ( space , w_val ) : <EOL> """<STR_LIT>""" <EOL> return space . hex ( w_val ) <EOL> def id ( space , w_object ) : <EOL> "<STR_LIT>" <EOL> return space . id ( w_object ) <EOL> def cmp ( space , w_x , w_y ) : <EOL> """<STR_LIT>""" <EOL> return space . cmp ( w_x , w_y ) <EOL> def coerce ( space , w_x , w_y ) : <EOL> """<STR_LIT>""" <EOL> return space . coerce ( w_x , w_y ) <EOL> def divmod ( space , w_x , w_y ) : <EOL> """<STR_LIT>""" <EOL> return space . divmod ( w_x , w_y ) <EOL> def _issubtype ( space , w_cls1 , w_cls2 ) : <EOL> return space . issubtype ( w_cls1 , w_cls2 ) <EOL> from math import floor as _floor <EOL> from math import ceil as _ceil <EOL> def round ( space , number , ndigits = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> f = <NUM_LIT:1.0> <EOL> if ndigits < <NUM_LIT:0> : <EOL> i = - ndigits <EOL> else : <EOL> i = ndigits <EOL> while i > <NUM_LIT:0> : <EOL> f = f * <NUM_LIT> <EOL> i -= <NUM_LIT:1> <EOL> if ndigits < <NUM_LIT:0> : <EOL> number /= f <EOL> else : <EOL> number *= f <EOL> if number >= <NUM_LIT:0.0> : <EOL> number = _floor ( number + <NUM_LIT:0.5> ) <EOL> else : <EOL> number = _ceil ( number - <NUM_LIT:0.5> ) <EOL> if ndigits < <NUM_LIT:0> : <EOL> number *= f <EOL> else : <EOL> number /= f <EOL> return space . wrap ( number ) <EOL> round . unwrap_spec = [ ObjSpace , float , int ] <EOL> iter_sentinel = gateway . applevel ( '''<STR_LIT>''' , filename = __file__ ) . interphook ( "<STR_LIT>" ) <EOL> def iter ( space , w_collection_or_callable , w_sentinel = NoneNotWrapped ) : <EOL> """<STR_LIT>""" <EOL> if w_sentinel is None : <EOL> return space . iter ( w_collection_or_callable ) <EOL> else : <EOL> return iter_sentinel ( space , w_collection_or_callable , w_sentinel ) <EOL> def ord ( space , w_val ) : <EOL> """<STR_LIT>""" <EOL> return space . ord ( w_val ) <EOL> def pow ( space , w_base , w_exponent , w_modulus = None ) : <EOL> """<STR_LIT>""" <EOL> return space . pow ( w_base , w_exponent , w_modulus ) <EOL> def repr ( space , w_object ) : <EOL> """<STR_LIT>""" <EOL> return space . repr ( w_object ) <EOL> def setattr ( space , w_object , w_name , w_val ) : <EOL> """<STR_LIT>""" <EOL> w_name = checkattrname ( space , w_name ) <EOL> space . setattr ( w_object , w_name , w_val ) <EOL> return space . w_None <EOL> def intern ( space , w_str ) : <EOL> """<STR_LIT>""" <EOL> if space . is_w ( space . type ( w_str ) , space . w_str ) : <EOL> return space . new_interned_w_str ( w_str ) <EOL> raise OperationError ( space . w_TypeError , space . wrap ( "<STR_LIT>" ) ) <EOL> def callable ( space , w_object ) : <EOL> """<STR_LIT>""" <EOL> return space . callable ( w_object ) </s>
