[pypy-commit] pypy remove-remaining-smm: Move wrap_parsestringerror() -> pypy.objspace.std.util.
Manuel Jacob
noreply at buildbot.pypy.org
Mon Feb 24 04:10:25 CET 2014
Author: Manuel Jacob
Branch: remove-remaining-smm
Changeset: r69335:82db216f833a
Date: 2014-02-24 04:09 +0100
http://bitbucket.org/pypy/pypy/changeset/82db216f833a/
Log: Move wrap_parsestringerror() -> pypy.objspace.std.util.
diff --git a/pypy/objspace/std/floatobject.py b/pypy/objspace/std/floatobject.py
--- a/pypy/objspace/std/floatobject.py
+++ b/pypy/objspace/std/floatobject.py
@@ -9,6 +9,7 @@
from pypy.objspace.std import newformat
from pypy.objspace.std.longobject import W_LongObject
from pypy.objspace.std.stdtypedef import StdTypeDef
+from pypy.objspace.std.util import wrap_parsestringerror
from rpython.rlib import rarithmetic, rfloat
from rpython.rlib.rarithmetic import ovfcheck_float_to_int, intmask, LONG_BIT
from rpython.rlib.rbigint import rbigint
@@ -168,7 +169,6 @@
try:
return rfloat.string_to_float(string)
except ParseStringError as e:
- from pypy.objspace.std.intobject import wrap_parsestringerror
raise wrap_parsestringerror(space, e, w_source)
w_value = w_x # 'x' is the keyword argument name in CPython
diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py
--- a/pypy/objspace/std/intobject.py
+++ b/pypy/objspace/std/intobject.py
@@ -13,8 +13,7 @@
from rpython.rlib.rarithmetic import (
LONG_BIT, is_valid_int, ovfcheck, r_longlong, r_uint, string_to_int)
from rpython.rlib.rbigint import rbigint
-from rpython.rlib.rstring import (
- InvalidBaseError, ParseStringError, ParseStringOverflowError)
+from rpython.rlib.rstring import ParseStringError, ParseStringOverflowError
from rpython.tool.sourcetools import func_renamer, func_with_new_name
from pypy.interpreter import typedef
@@ -26,6 +25,7 @@
from pypy.objspace.std.model import (
BINARY_OPS, CMP_OPS, COMMUTATIVE_OPS, IDTAG_INT)
from pypy.objspace.std.stdtypedef import StdTypeDef
+from pypy.objspace.std.util import wrap_parsestringerror
SENTINEL = object()
@@ -605,15 +605,6 @@
return w_res
-def wrap_parsestringerror(space, e, w_source):
- if isinstance(e, InvalidBaseError):
- w_msg = space.wrap(e.msg)
- else:
- w_msg = space.wrap('%s: %s' % (e.msg,
- space.str_w(space.repr(w_source))))
- return OperationError(space.w_ValueError, w_msg)
-
-
def _recover_with_smalllong(space):
"""True if there is a chance that a SmallLong would fit when an Int
does not
diff --git a/pypy/objspace/std/util.py b/pypy/objspace/std/util.py
--- a/pypy/objspace/std/util.py
+++ b/pypy/objspace/std/util.py
@@ -1,3 +1,7 @@
+from pypy.interpreter.error import oefmt
+from rpython.rlib.rstring import InvalidBaseError
+
+
def negate(f):
"""Create a function which calls `f` and negates its result. When the
result is ``space.w_NotImplemented``, ``space.w_NotImplemented`` is
@@ -22,3 +26,11 @@
where = length
assert where >= 0
return where
+
+
+def wrap_parsestringerror(space, e, w_source):
+ if isinstance(e, InvalidBaseError):
+ raise oefmt(space.w_ValueError, e.msg)
+ else:
+ raise oefmt(space.w_ValueError, '%s: %s',
+ e.msg, space.str_w(space.repr(w_source)))
More information about the pypy-commit
mailing list