def test_from_numberstring_parser_no_implicit_octal(self): from rpython.rlib.rstring import NumberStringParser, ParseStringError s = "077777777777777777777777777777" parser = NumberStringParser(s, s, 0, "long", no_implicit_octal=True) with pytest.raises(ParseStringError): rbigint._from_numberstring_parser(parser) parser = NumberStringParser("000", "000", 0, "long", no_implicit_octal=True) assert rbigint._from_numberstring_parser(parser).tolong() == 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)
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)
def retry_to_w_long(space, parser): parser.rewind() try: bigint = rbigint._from_numberstring_parser(parser) except ParseStringError, e: raise OperationError(space.w_ValueError, space.wrap(e.msg))
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)
def parse_integer(string, base=10): if base > 36: raise ValueError("Not enough digits to base") if base < 0: raise ValueError("Negative base") literal = string parser = NumberStringParser(string, literal, base, 'long') return Integer(rbigint._from_numberstring_parser(parser))
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)
def test_from_numberstring_parser(self): from rpython.rlib.rstring import NumberStringParser parser = NumberStringParser("1231231241", "1231231241", 10, "long") assert rbigint._from_numberstring_parser(parser).tolong() == 1231231241
def retry_to_w_long(space, parser): parser.rewind() try: bigint = rbigint._from_numberstring_parser(parser) except ParseStringError, e: raise OperationError(space.w_ValueError, space.wrap(e.msg))