Author: Brian Kearns <[email protected]>
Branch:
Changeset: r68421:1320c7d5c78d
Date: 2013-12-13 15:44 -0500
http://bitbucket.org/pypy/pypy/changeset/1320c7d5c78d/
Log: cleanup inttype
diff --git a/pypy/objspace/std/inttype.py b/pypy/objspace/std/inttype.py
--- a/pypy/objspace/std/inttype.py
+++ b/pypy/objspace/std/inttype.py
@@ -91,11 +91,9 @@
w_value = w_x # 'x' is the keyword argument name in CPython
value = 0
if w_base is None:
- ok = False
# check for easy cases
if type(w_value) is W_IntObject:
value = w_value.intval
- ok = True
elif space.lookup(w_value, '__int__') is not None or \
space.lookup(w_value, '__trunc__') is not None:
# otherwise, use the __int__() or the __trunc__() methods
@@ -110,21 +108,13 @@
# int_w is effectively what we want in this case,
# we cannot construct a subclass of int instance with an
# an overflowing long
- try:
- value = space.int_w(w_obj)
- except OperationError, e:
- if not e.match(space, space.w_TypeError):
- raise
- else:
- ok = True
+ value = space.int_w(w_obj)
elif space.isinstance_w(w_value, space.w_str):
value, w_longval = string_to_int_or_long(space,
space.str_w(w_value))
- ok = True
elif space.isinstance_w(w_value, space.w_unicode):
from pypy.objspace.std.unicodeobject import unicode_to_decimal_w
string = unicode_to_decimal_w(space, w_value)
value, w_longval = string_to_int_or_long(space, string)
- ok = True
else:
# If object supports the buffer interface
try:
@@ -132,15 +122,12 @@
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
+ raise operationerrfmt(space.w_TypeError,
+ "int() argument must be a string or a number, not '%T'",
+ w_value)
else:
buf = space.interp_w(Buffer, w_buffer)
value, w_longval = string_to_int_or_long(space, buf.as_str())
- ok = True
-
- if not ok:
- raise operationerrfmt(space.w_TypeError,
- "int() argument must be a string or a number, not '%T'",
- w_value)
else:
base = space.int_w(w_base)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit