示例#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)
示例#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)
示例#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)
示例#4
0
文件: intobject.py 项目: Qointum/pypy
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)
示例#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
示例#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
示例#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)
示例#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
示例#9
0
文件: intobject.py 项目: Qointum/pypy
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
示例#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)
示例#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)
示例#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)
示例#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)
示例#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)