Author: Hakan Ardo <ha...@debian.org> Branch: Changeset: r66172:f4f5fae1001d Date: 2013-08-16 09:55 +0200 http://bitbucket.org/pypy/pypy/changeset/f4f5fae1001d/
Log: merge diff --git a/pypy/module/_file/interp_file.py b/pypy/module/_file/interp_file.py --- a/pypy/module/_file/interp_file.py +++ b/pypy/module/_file/interp_file.py @@ -437,14 +437,14 @@ return self.getrepr(self.space, info) def getdisplayname(self): + space = self.space w_name = self.w_name if w_name is None: return '?' - elif self.space.is_true(self.space.isinstance(w_name, - self.space.w_str)): - return "'%s'" % self.space.str_w(w_name) + elif space.isinstance_w(w_name, space.w_str): + return "'%s'" % space.str_w(w_name) else: - return self.space.str_w(self.space.repr(w_name)) + return space.str_w(space.repr(w_name)) def file_writelines(self, w_lines): """writelines(sequence_of_strings) -> None. Write the strings to the file. diff --git a/pypy/module/micronumpy/test/test_complex.py b/pypy/module/micronumpy/test/test_complex.py --- a/pypy/module/micronumpy/test/test_complex.py +++ b/pypy/module/micronumpy/test/test_complex.py @@ -685,3 +685,8 @@ msg=error_message) sys.stderr.write('.') sys.stderr.write('\n') + + def test_complexbox_to_pycomplex(self): + from numpypy import complex128 + x = complex128(3.4j) + assert complex(x) == 3.4j diff --git a/pypy/objspace/std/bytearrayobject.py b/pypy/objspace/std/bytearrayobject.py --- a/pypy/objspace/std/bytearrayobject.py +++ b/pypy/objspace/std/bytearrayobject.py @@ -7,7 +7,6 @@ from pypy.objspace.std.bytearraytype import ( getbytevalue, makebytearraydata_w, new_bytearray) from pypy.objspace.std.intobject import W_IntObject -from pypy.objspace.std.inttype import wrapint from pypy.objspace.std.model import W_Object, registerimplementation from pypy.objspace.std.multimethod import FailedToImplement from pypy.objspace.std.noneobject import W_NoneObject @@ -76,7 +75,7 @@ def len__Bytearray(space, w_bytearray): result = len(w_bytearray.data) - return wrapint(space, result) + return space.newint(result) def ord__Bytearray(space, w_bytearray): if len(w_bytearray.data) != 1: diff --git a/pypy/objspace/std/complextype.py b/pypy/objspace/std/complextype.py --- a/pypy/objspace/std/complextype.py +++ b/pypy/objspace/std/complextype.py @@ -201,7 +201,7 @@ if w_z is not None: # __complex__() must return a complex or (float,int,long) object # (XXX should not use isinstance here) - if not strict_typing and (space.isinstance_w(w_z, space.w_int) or + if not strict_typing and (space.isinstance_w(w_z, space.w_int) or space.isinstance_w(w_z, space.w_long) or space.isinstance_w(w_z, space.w_float)): return (space.float_w(w_z), 0.0) @@ -214,8 +214,10 @@ # # no '__complex__' method, so we assume it is a float, # unless it is an instance of some subclass of complex. - if isinstance(w_complex, W_ComplexObject): - return (w_complex.realval, w_complex.imagval) + if space.isinstance_w(w_complex, space.gettypefor(W_ComplexObject)): + real = space.float(space.getattr(w_complex, space.wrap("real"))) + imag = space.float(space.getattr(w_complex, space.wrap("imag"))) + return (space.float_w(real), space.float_w(imag)) # # Check that it is not a string (on which space.float() would succeed). if (space.isinstance_w(w_complex, space.w_str) or 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 @@ -1,6 +1,6 @@ from pypy.interpreter.error import OperationError from pypy.objspace.std import newformat -from pypy.objspace.std.inttype import wrapint, W_AbstractIntObject +from pypy.objspace.std.inttype import W_AbstractIntObject from pypy.objspace.std.model import registerimplementation, W_Object from pypy.objspace.std.multimethod import FailedToImplementArgs from pypy.objspace.std.noneobject import W_NoneObject @@ -55,7 +55,7 @@ if space.is_w(space.type(self), space.w_int): return self a = self.intval - return wrapint(space, a) + return space.newint(a) registerimplementation(W_IntObject) @@ -104,7 +104,7 @@ except OverflowError: raise FailedToImplementArgs(space.w_OverflowError, space.wrap("integer addition")) - return wrapint(space, z) + return space.newint(z) def sub__Int_Int(space, w_int1, w_int2): x = w_int1.intval @@ -114,7 +114,7 @@ except OverflowError: raise FailedToImplementArgs(space.w_OverflowError, space.wrap("integer substraction")) - return wrapint(space, z) + return space.newint(z) def mul__Int_Int(space, w_int1, w_int2): x = w_int1.intval @@ -124,7 +124,7 @@ except OverflowError: raise FailedToImplementArgs(space.w_OverflowError, space.wrap("integer multiplication")) - return wrapint(space, z) + return space.newint(z) def floordiv__Int_Int(space, w_int1, w_int2): x = w_int1.intval @@ -137,7 +137,7 @@ except OverflowError: raise FailedToImplementArgs(space.w_OverflowError, space.wrap("integer division")) - return wrapint(space, z) + return space.newint(z) div__Int_Int = floordiv__Int_Int def truediv__Int_Int(space, w_int1, w_int2): @@ -158,7 +158,7 @@ except OverflowError: raise FailedToImplementArgs(space.w_OverflowError, space.wrap("integer modulo")) - return wrapint(space, z) + return space.newint(z) def divmod__Int_Int(space, w_int1, w_int2): x = w_int1.intval @@ -231,7 +231,7 @@ except OverflowError: raise FailedToImplementArgs(space.w_OverflowError, space.wrap("integer negation")) - return wrapint(space, x) + return space.newint(x) get_negint = neg__Int @@ -247,7 +247,7 @@ def invert__Int(space, w_int1): x = w_int1.intval a = ~x - return wrapint(space, a) + return space.newint(a) def lshift__Int_Int(space, w_int1, w_int2): a = w_int1.intval @@ -258,7 +258,7 @@ except OverflowError: raise FailedToImplementArgs(space.w_OverflowError, space.wrap("integer left shift")) - return wrapint(space, c) + return space.newint(c) if b < 0: raise OperationError(space.w_ValueError, space.wrap("negative shift count")) @@ -284,25 +284,25 @@ a = 0 else: a = a >> b - return wrapint(space, a) + return space.newint(a) def and__Int_Int(space, w_int1, w_int2): a = w_int1.intval b = w_int2.intval res = a & b - return wrapint(space, res) + return space.newint(res) def xor__Int_Int(space, w_int1, w_int2): a = w_int1.intval b = w_int2.intval res = a ^ b - return wrapint(space, res) + return space.newint(res) def or__Int_Int(space, w_int1, w_int2): a = w_int1.intval b = w_int2.intval res = a | b - return wrapint(space, res) + return space.newint(res) def pos__Int(self, space): return self.int(space) @@ -323,7 +323,7 @@ return space.wrap(hex(w_int1.intval)) def getnewargs__Int(space, w_int1): - return space.newtuple([wrapint(space, w_int1.intval)]) + return space.newtuple([space.newint(w_int1.intval)]) register_all(vars()) diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -19,7 +19,6 @@ from pypy.objspace.std import slicetype from pypy.objspace.std.floatobject import W_FloatObject from pypy.objspace.std.intobject import W_IntObject -from pypy.objspace.std.inttype import wrapint from pypy.objspace.std.iterobject import (W_FastListIterObject, W_ReverseSeqIterObject) from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice @@ -427,7 +426,7 @@ def descr_len(self, space): result = self.length() - return wrapint(space, result) + return space.newint(result) def descr_iter(self, space): return W_FastListIterObject(self) diff --git a/pypy/objspace/std/stringobject.py b/pypy/objspace/std/stringobject.py --- a/pypy/objspace/std/stringobject.py +++ b/pypy/objspace/std/stringobject.py @@ -4,7 +4,6 @@ from pypy.interpreter.error import OperationError, operationerrfmt from pypy.objspace.std import newformat, slicetype from pypy.objspace.std.formatting import mod_format -from pypy.objspace.std.inttype import wrapint from pypy.objspace.std.model import W_Object, registerimplementation from pypy.objspace.std.multimethod import FailedToImplement from pypy.objspace.std.noneobject import W_NoneObject @@ -589,7 +588,7 @@ def str_count__String_String_ANY_ANY(space, w_self, w_arg, w_start, w_end): u_self, u_start, u_end = _convert_idx_params(space, w_self, w_start, w_end) - return wrapint(space, u_self.count(w_arg._value, u_start, u_end)) + return space.newint(u_self.count(w_arg._value, u_start, u_end)) def str_endswith__String_String_ANY_ANY(space, w_self, w_suffix, w_start, w_end): (u_self, start, end) = _convert_idx_params(space, w_self, w_start, @@ -709,7 +708,7 @@ def hash__String(space, w_str): s = w_str._value x = compute_hash(s) - return wrapint(space, x) + return space.newint(x) def lt__String_String(space, w_str1, w_str2): s1 = w_str1._value diff --git a/pypy/objspace/std/tupleobject.py b/pypy/objspace/std/tupleobject.py --- a/pypy/objspace/std/tupleobject.py +++ b/pypy/objspace/std/tupleobject.py @@ -7,7 +7,6 @@ from pypy.interpreter.gateway import ( WrappedDefault, interp2app, interpindirect2app, unwrap_spec) from pypy.objspace.std import slicetype -from pypy.objspace.std.inttype import wrapint from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice from pypy.objspace.std.stdtypedef import StdTypeDef from pypy.objspace.std.util import negate @@ -56,7 +55,7 @@ def descr_len(self, space): result = self.length() - return wrapint(space, result) + return space.newint(result) def descr_iter(self, space): from pypy.objspace.std import iterobject diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py --- a/pypy/tool/jitlogparser/parser.py +++ b/pypy/tool/jitlogparser/parser.py @@ -382,7 +382,7 @@ from rpython.jit.backend.tool.viewcode import World world = World() for entry in extract_category(log, 'jit-backend-dump'): - world.parse(entry.splitlines(True), truncate_addr=False) + world.parse(entry.splitlines(True)) dumps = {} for r in world.ranges: if r.addr in addrs and addrs[r.addr]: _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit