<s> import sys <EOL> from pypy . interpreter import baseobjspace <EOL> from pypy . objspace . std . stdtypedef import * <EOL> from pypy . objspace . std . register_all import register_all <EOL> from pypy . interpreter . error import OperationError <EOL> slice_indices = SMM ( '<STR_LIT>' , <NUM_LIT:2> , <EOL> doc = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> def _Eval_SliceIndex ( space , w_int ) : <EOL> try : <EOL> return space . getindex_w ( w_int , None ) <EOL> except OperationError , err : <EOL> if not err . match ( space , space . w_TypeError ) : <EOL> raise <EOL> raise OperationError ( space . w_TypeError , <EOL> space . wrap ( "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> def adapt_lower_bound ( space , size , w_index ) : <EOL> index = _Eval_SliceIndex ( space , w_index ) <EOL> if index < <NUM_LIT:0> : <EOL> index = index + size <EOL> if index < <NUM_LIT:0> : <EOL> index = <NUM_LIT:0> <EOL> assert index >= <NUM_LIT:0> <EOL> return index <EOL> def adapt_bound ( space , size , w_index ) : <EOL> index = _Eval_SliceIndex ( space , w_index ) <EOL> if index < <NUM_LIT:0> : <EOL> index = index + size <EOL> if index < <NUM_LIT:0> : <EOL> index = <NUM_LIT:0> <EOL> if index > size : <EOL> index = size <EOL> assert index >= <NUM_LIT:0> <EOL> return index <EOL> register_all ( vars ( ) , globals ( ) ) <EOL> def descr__new__ ( space , w_slicetype , args_w ) : <EOL> from pypy . objspace . std . sliceobject import W_SliceObject <EOL> w_start = space . w_None <EOL> w_stop = space . w_None <EOL> w_step = space . w_None <EOL> if len ( args_w ) == <NUM_LIT:1> : <EOL> w_stop , = args_w <EOL> elif len ( args_w ) == <NUM_LIT:2> : <EOL> w_start , w_stop = args_w <EOL> elif len ( args_w ) == <NUM_LIT:3> : <EOL> w_start , w_stop , w_step = args_w <EOL> elif len ( args_w ) > <NUM_LIT:3> : <EOL> raise OperationError ( space . w_TypeError , <EOL> space . wrap ( "<STR_LIT>" ) ) <EOL> else : <EOL> raise OperationError ( space . w_TypeError , <EOL> space . wrap ( "<STR_LIT>" ) ) <EOL> w_obj = space . allocate_instance ( W_SliceObject , w_slicetype ) <EOL> W_SliceObject . __init__ ( w_obj , w_start , w_stop , w_step ) <EOL> return w_obj <EOL> descr__new__ . unwrap_spec = [ baseobjspace . ObjSpace , baseobjspace . W_Root , <EOL> '<STR_LIT>' ] <EOL> def slicewprop ( name ) : <EOL> def fget ( space , w_obj ) : <EOL> from pypy . objspace . std . sliceobject import W_SliceObject <EOL> if not isinstance ( w_obj , W_SliceObject ) : <EOL> raise OperationError ( space . w_TypeError , <EOL> space . wrap ( "<STR_LIT>" ) ) <EOL> return getattr ( w_obj , name ) <EOL> return GetSetProperty ( fget ) <EOL> slice_typedef = StdTypeDef ( "<STR_LIT>" , <EOL> __doc__ = '''<STR_LIT>''' , <EOL> __new__ = newmethod ( descr__new__ ) , <EOL> __hash__ = no_hash_descr , <EOL> start = slicewprop ( '<STR_LIT>' ) , <EOL> stop = slicewprop ( '<STR_LIT>' ) , <EOL> step = slicewprop ( '<STR_LIT>' ) , <EOL> ) <EOL> slice_typedef . acceptable_as_base_class = False <EOL> slice_typedef . registermethods ( globals ( ) ) </s>
