예제 #1
0
파일: intobject.py 프로젝트: sota/pypy-old
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
파일: intobject.py 프로젝트: sota/pypy-old
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
파일: longobject.py 프로젝트: zcxowwww/pypy
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)