Esempio n. 1
0
def _retry_to_w_long(space, parser, w_source):
    parser.rewind()
    try:
        bigint = rbigint._from_numberstring_parser(parser)
    except ParseStringError as e:
        raise wrap_parsestringerror(space, e, w_source)
    return space.newlong_from_rbigint(bigint)
Esempio n. 2
0
def _retry_to_w_long(space, parser, w_source):
    parser.rewind()
    try:
        bigint = rbigint._from_numberstring_parser(parser)
    except ParseStringError as e:
        raise wrap_parsestringerror(space, e, w_source)
    return space.newlong_from_rbigint(bigint)
Esempio n. 3
0
def _retry_to_w_long(space, parser, w_inttype, w_source):
    from pypy.objspace.std.longobject import newbigint
    parser.rewind()
    try:
        bigint = rbigint._from_numberstring_parser(parser)
    except ParseStringError as e:
        raise wrap_parsestringerror(space, e, w_source)
    return newbigint(space, w_inttype, bigint)
Esempio n. 4
0
def _retry_to_w_long(space, parser, w_inttype, w_source):
    from pypy.objspace.std.longobject import newbigint

    parser.rewind()
    try:
        bigint = rbigint._from_numberstring_parser(parser)
    except ParseStringError as e:
        raise wrap_parsestringerror(space, e, w_source)
    return newbigint(space, w_inttype, bigint)
Esempio n. 5
0
def _string_to_int_or_long(space, w_source, string, base=10):
    w_longval = None
    value = 0
    try:
        value = string_to_int(string, base)
    except ParseStringError as e:
        raise wrap_parsestringerror(space, e, w_source)
    except ParseStringOverflowError as e:
        w_longval = _retry_to_w_long(space, e.parser, w_source)
    return value, w_longval
Esempio n. 6
0
def _string_to_int_or_long(space, w_source, string, base=10):
    w_longval = None
    value = 0
    try:
        value = string_to_int(string, base)
    except ParseStringError as e:
        raise wrap_parsestringerror(space, e, w_source)
    except ParseStringOverflowError as e:
        w_longval = _retry_to_w_long(space, e.parser, w_source)
    return value, w_longval
Esempio n. 7
0
def _string_to_int_or_long(space, w_source, string, base=10):
    try:
        value = string_to_int(string,
                              base,
                              allow_underscores=True,
                              no_implicit_octal=True)
        return wrapint(space, value)
    except ParseStringError as e:
        raise wrap_parsestringerror(space, e, w_source)
    except ParseStringOverflowError as e:
        return _retry_to_w_long(space, e.parser, w_source)
Esempio n. 8
0
def _string_to_int_or_long(space, w_inttype, w_source, string, base=10):
    try:
        value = string_to_int(string, base)
    except ParseStringError as e:
        raise wrap_parsestringerror(space, e, w_source)
    except ParseStringOverflowError as e:
        return _retry_to_w_long(space, e.parser, w_inttype, w_source)

    if space.is_w(w_inttype, space.w_int):
        w_result = wrapint(space, value)
    else:
        w_result = space.allocate_instance(W_IntObject, w_inttype)
        W_IntObject.__init__(w_result, value)
    return w_result
Esempio n. 9
0
def _string_to_int_or_long(space, w_inttype, w_source, string, base=10):
    try:
        value = string_to_int(string, base)
    except ParseStringError as e:
        raise wrap_parsestringerror(space, e, w_source)
    except ParseStringOverflowError as e:
        return _retry_to_w_long(space, e.parser, w_inttype, w_source)

    if space.is_w(w_inttype, space.w_int):
        w_result = wrapint(space, value)
    else:
        w_result = space.allocate_instance(W_IntObject, w_inttype)
        W_IntObject.__init__(w_result, value)
    return w_result
Esempio n. 10
0
 def save_field(self, field_builder):
     space = self.space
     field = field_builder.build()
     if self.numeric_field:
         from rpython.rlib.rstring import ParseStringError
         from rpython.rlib.rfloat import string_to_float
         self.numeric_field = False
         try:
             ff = string_to_float(field)
         except ParseStringError as e:
             raise wrap_parsestringerror(space, e, space.wrap(field))
         w_obj = space.wrap(ff)
     else:
         w_obj = space.wrap(field)
     self.fields_w.append(w_obj)
Esempio n. 11
0
 def save_field(self, field_builder):
     space = self.space
     field = field_builder.build()
     if self.numeric_field:
         from rpython.rlib.rstring import ParseStringError
         from rpython.rlib.rfloat import string_to_float
         self.numeric_field = False
         try:
             ff = string_to_float(field)
         except ParseStringError as e:
             raise wrap_parsestringerror(space, e, space.wrap(field))
         w_obj = space.wrap(ff)
     else:
         w_obj = space.wrap(field)
     self.fields_w.append(w_obj)
Esempio n. 12
0
 def _string_to_float(space, w_source, string):
     try:
         return rfloat.string_to_float(string)
     except ParseStringError as e:
         raise wrap_parsestringerror(space, e, w_source)
Esempio n. 13
0
def _string_to_w_long(space, w_longtype, w_source, string, base=10):
    try:
        bigint = rbigint.fromstr(string, base)
    except ParseStringError as e:
        raise wrap_parsestringerror(space, e, w_source)
    return newbigint(space, w_longtype, bigint)
Esempio n. 14
0
def _string_to_w_long(space, w_longtype, w_source, string, base=10):
    try:
        bigint = rbigint.fromstr(string, base)
    except ParseStringError as e:
        raise wrap_parsestringerror(space, e, w_source)
    return newbigint(space, w_longtype, bigint)