<s> from pypy . objspace . std . stdtypedef import * <EOL> from pypy . interpreter . error import OperationError <EOL> from pypy . objspace . std . strutil import string_to_float , ParseStringError <EOL> from pypy . objspace . std . strutil import interp_string_to_float <EOL> USE_NEW_S2F = True <EOL> def descr__new__ ( space , w_floattype , w_x = <NUM_LIT:0.0> ) : <EOL> from pypy . objspace . std . floatobject import W_FloatObject <EOL> w_value = w_x <EOL> if space . is_true ( space . isinstance ( w_value , space . w_str ) ) : <EOL> strvalue = space . str_w ( w_value ) <EOL> try : <EOL> if USE_NEW_S2F : <EOL> value = interp_string_to_float ( space , strvalue ) <EOL> else : <EOL> value = string_to_float ( strvalue ) <EOL> except ParseStringError , e : <EOL> raise OperationError ( space . w_ValueError , <EOL> space . wrap ( e . msg ) ) <EOL> elif space . is_true ( space . isinstance ( w_value , space . w_unicode ) ) : <EOL> if space . config . objspace . std . withropeunicode : <EOL> from pypy . objspace . std . ropeunicodeobject import unicode_to_decimal_w <EOL> else : <EOL> from unicodeobject import unicode_to_decimal_w <EOL> strvalue = unicode_to_decimal_w ( space , w_value ) <EOL> try : <EOL> if USE_NEW_S2F : <EOL> value = interp_string_to_float ( space , strvalue ) <EOL> else : <EOL> value = string_to_float ( strvalue ) <EOL> except ParseStringError , e : <EOL> raise OperationError ( space . w_ValueError , <EOL> space . wrap ( e . msg ) ) <EOL> else : <EOL> w_obj = space . float ( w_value ) <EOL> if space . is_w ( w_floattype , space . w_float ) : <EOL> return w_obj <EOL> value = space . float_w ( w_obj ) <EOL> w_obj = space . allocate_instance ( W_FloatObject , w_floattype ) <EOL> W_FloatObject . __init__ ( w_obj , value ) <EOL> return w_obj <EOL> float_typedef = StdTypeDef ( "<STR_LIT:float>" , <EOL> __doc__ = '''<STR_LIT>''' , <EOL> __new__ = newmethod ( descr__new__ ) , <EOL> ) </s>
