[pypy-commit] pypy py3k: merge default
pjenvey
noreply at buildbot.pypy.org
Wed Mar 19 06:11:33 CET 2014
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r70082:1cf13b13b4a1
Date: 2014-03-18 22:08 -0700
http://bitbucket.org/pypy/pypy/changeset/1cf13b13b4a1/
Log: merge default
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -194,6 +194,11 @@
return None
def buffer_w(self, space):
+ w_impl = space.lookup(self, '__buffer__')
+ if w_impl is not None:
+ w_result = space.get_and_call_function(w_impl, self)
+ if space.isinstance_w(w_result, space.w_buffer):
+ return w_result.buffer_w(space)
self._typed_unwrap_error(space, "buffer")
def bytes_w(self, space):
diff --git a/pypy/interpreter/buffer.py b/pypy/interpreter/buffer.py
--- a/pypy/interpreter/buffer.py
+++ b/pypy/interpreter/buffer.py
@@ -1,7 +1,6 @@
"""
Buffer protocol support.
"""
-from pypy.interpreter.error import OperationError
from rpython.rlib.objectmodel import import_from_mixin
@@ -71,8 +70,8 @@
assert 0 <= start <= stop
return self.value[start:stop]
return "".join([self.value[start + i*step] for i in xrange(size)])
+# ____________________________________________________________
-# ____________________________________________________________
class SubBufferMixin(object):
_attrs_ = ['buffer', 'offset', 'size']
@@ -98,7 +97,8 @@
if start == stop:
return '' # otherwise, adding self.offset might make them
# out of bounds
- return self.buffer.getslice(self.offset + start, self.offset + stop, step, size)
+ return self.buffer.getslice(self.offset + start, self.offset + stop,
+ step, size)
class SubBuffer(Buffer):
diff --git a/pypy/module/__pypy__/interp_builders.py b/pypy/module/__pypy__/interp_builders.py
--- a/pypy/module/__pypy__/interp_builders.py
+++ b/pypy/module/__pypy__/interp_builders.py
@@ -4,7 +4,6 @@
from pypy.interpreter.typedef import TypeDef
from rpython.rlib.rstring import UnicodeBuilder, StringBuilder
from rpython.tool.sourcetools import func_with_new_name
-from rpython.rlib import jit
def create_builder(name, strtype, builder_cls):
diff --git a/pypy/module/_cffi_backend/cbuffer.py b/pypy/module/_cffi_backend/cbuffer.py
--- a/pypy/module/_cffi_backend/cbuffer.py
+++ b/pypy/module/_cffi_backend/cbuffer.py
@@ -1,4 +1,3 @@
-from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.buffer import RWBuffer
from pypy.interpreter.error import oefmt
from pypy.interpreter.gateway import unwrap_spec, interp2app
diff --git a/pypy/module/_cffi_backend/ctypestruct.py b/pypy/module/_cffi_backend/ctypestruct.py
--- a/pypy/module/_cffi_backend/ctypestruct.py
+++ b/pypy/module/_cffi_backend/ctypestruct.py
@@ -80,7 +80,6 @@
return (cfield.ctype, cfield.offset)
def _copy_from_same(self, cdata, w_ob):
- space = self.space
if isinstance(w_ob, cdataobj.W_CData):
if w_ob.ctype is self and self.size >= 0:
misc._raw_memcopy(w_ob._cdata, cdata, self.size)
diff --git a/pypy/module/_cffi_backend/handle.py b/pypy/module/_cffi_backend/handle.py
--- a/pypy/module/_cffi_backend/handle.py
+++ b/pypy/module/_cffi_backend/handle.py
@@ -1,4 +1,3 @@
-import weakref
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import unwrap_spec
from pypy.module._cffi_backend import ctypeobj, ctypeptr, cdataobj
diff --git a/pypy/module/_cffi_backend/misc.py b/pypy/module/_cffi_backend/misc.py
--- a/pypy/module/_cffi_backend/misc.py
+++ b/pypy/module/_cffi_backend/misc.py
@@ -4,7 +4,7 @@
from rpython.rlib import jit
from rpython.rlib.objectmodel import keepalive_until_here, specialize
-from rpython.rlib.rarithmetic import r_uint, r_ulonglong, is_signed_integer_type
+from rpython.rlib.rarithmetic import r_uint, r_ulonglong
from rpython.rlib.unroll import unrolling_iterable
from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
from rpython.translator.tool.cbuild import ExternalCompilationInfo
diff --git a/pypy/module/_minimal_curses/fficurses.py b/pypy/module/_minimal_curses/fficurses.py
--- a/pypy/module/_minimal_curses/fficurses.py
+++ b/pypy/module/_minimal_curses/fficurses.py
@@ -1,4 +1,3 @@
-
""" The ffi for rpython, need to be imported for side effects
"""
@@ -8,8 +7,6 @@
from rpython.rtyper.extfunc import register_external
from pypy.module._minimal_curses import interp_curses
from rpython.translator.tool.cbuild import ExternalCompilationInfo
-from sys import platform
-import os.path
# We cannot trust ncurses5-config, it's broken in various ways in
# various versions. For example it might not list -ltinfo even though
diff --git a/pypy/module/_pickle_support/maker.py b/pypy/module/_pickle_support/maker.py
--- a/pypy/module/_pickle_support/maker.py
+++ b/pypy/module/_pickle_support/maker.py
@@ -3,7 +3,6 @@
from pypy.interpreter.pycode import PyCode
from pypy.interpreter.function import Function, Method
from pypy.interpreter.module import Module
-from pypy.interpreter.pyframe import PyFrame
from pypy.interpreter.pytraceback import PyTraceback
from pypy.interpreter.generator import GeneratorIteratorWithDel
from rpython.rlib.objectmodel import instantiate
diff --git a/pypy/module/_pypyjson/interp_decoder.py b/pypy/module/_pypyjson/interp_decoder.py
--- a/pypy/module/_pypyjson/interp_decoder.py
+++ b/pypy/module/_pypyjson/interp_decoder.py
@@ -1,13 +1,10 @@
import sys
-import math
from rpython.rlib.rstring import StringBuilder
from rpython.rlib.objectmodel import specialize
from rpython.rlib import rfloat, runicode
from rpython.rtyper.lltypesystem import lltype, rffi
from pypy.interpreter.error import OperationError, oefmt
-from pypy.interpreter.gateway import unwrap_spec
from pypy.interpreter import unicodehelper
-from rpython.rtyper.annlowlevel import llstr, hlunicode
OVF_DIGITS = len(str(sys.maxint))
@@ -30,7 +27,7 @@
Internally it's implemented at the level of low-level helpers, to avoid
the extra copy we would need if we take the actual slice first.
-
+
No bound checking is done, use carefully.
"""
from rpython.rtyper.annlowlevel import llstr, hlunicode
@@ -226,7 +223,6 @@
def decode_array(self, i):
w_list = self.space.newlist([])
start = i
- count = 0
i = self.skip_whitespace(start)
if self.ll_chars[i] == ']':
self.pos = i+1
diff --git a/pypy/module/_rawffi/callback.py b/pypy/module/_rawffi/callback.py
--- a/pypy/module/_rawffi/callback.py
+++ b/pypy/module/_rawffi/callback.py
@@ -2,7 +2,7 @@
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.typedef import TypeDef, GetSetProperty
from rpython.rtyper.lltypesystem import lltype, rffi
-from pypy.module._rawffi.interp_rawffi import read_ptr, write_ptr
+from pypy.module._rawffi.interp_rawffi import write_ptr
from pypy.module._rawffi.structure import W_Structure
from pypy.module._rawffi.interp_rawffi import (W_DataInstance, letter2tp,
unwrap_value, unpack_argshapes, got_libffi_error)
diff --git a/pypy/module/_rawffi/structure.py b/pypy/module/_rawffi/structure.py
--- a/pypy/module/_rawffi/structure.py
+++ b/pypy/module/_rawffi/structure.py
@@ -15,7 +15,7 @@
from pypy.module._rawffi.interp_rawffi import size_alignment
from pypy.module._rawffi.interp_rawffi import read_ptr, write_ptr
from rpython.rlib import clibffi, rgc
-from rpython.rlib.rarithmetic import intmask, signedtype, widen, r_uint, \
+from rpython.rlib.rarithmetic import intmask, signedtype, r_uint, \
r_ulonglong
from rpython.rtyper.lltypesystem import lltype, rffi
diff --git a/pypy/module/_rawffi/tracker.py b/pypy/module/_rawffi/tracker.py
--- a/pypy/module/_rawffi/tracker.py
+++ b/pypy/module/_rawffi/tracker.py
@@ -1,4 +1,3 @@
-
""" The file that keeps track about freed/kept-alive objects allocated
by _rawffi. Used for debugging ctypes
"""
diff --git a/pypy/module/array/test/test_array.py b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -1,25 +1,8 @@
import sys
-import py
-import py.test
-
-
-## class AppTestSimpleArray:
-## spaceconfig = dict(usemodules=('array',))
-## def setup_class(cls):
-## cls.w_simple_array = cls.space.appexec([], """():
-## import array
-## return array.simple_array
-## """)
-
-## def test_simple(self):
-## a = self.simple_array(10)
-## a[5] = 7.42
-## assert a[5] == 7.42
+import pytest
class BaseArrayTests:
-
-
def test_ctor(self):
assert len(self.array('i')) == 0
@@ -545,7 +528,6 @@
assert not a > 2*a
assert not a >= 2*a
-
def test_reduce(self):
import pickle
a = self.array('i', [1, 2, 3])
@@ -779,7 +761,6 @@
assert img[3, 25] == 3 * 9
-
def test_override_from(self):
class mya(self.array):
def fromlist(self, lst):
@@ -862,41 +843,41 @@
def test_assign_object_with_special_methods(self):
from array import array
-
+
class Num(object):
def __float__(self):
return 5.25
-
+
def __int__(self):
return 7
-
+
class NotNum(object):
pass
-
+
class Silly(object):
def __float__(self):
return None
-
+
def __int__(self):
- return None
+ return None
class OldNum:
def __float__(self):
return 6.25
-
+
def __int__(self):
return 8
-
+
class OldNotNum:
pass
-
+
class OldSilly:
def __float__(self):
return None
-
+
def __int__(self):
return None
-
+
for tc in 'bBhHiIlL':
a = array(tc, [0])
raises(TypeError, a.__setitem__, 0, 1.0)
@@ -914,7 +895,7 @@
a = array(tc, [0])
a[0] = 1.0
a[0] = 1
- a[0] = Num()
+ a[0] = Num()
assert a[0] == 5.25
raises(TypeError, a.__setitem__, NotNum())
a[0] = OldNum()
@@ -922,11 +903,15 @@
raises(TypeError, a.__setitem__, OldNotNum())
raises(TypeError, a.__setitem__, Silly())
raises(TypeError, a.__setitem__, OldSilly())
-
+
a = array('u', 'hi')
a[0] = 'b'
assert a[0] == 'b'
-
+
+ a = array('u', u'hi')
+ a[0] = u'b'
+ assert a[0] == u'b'
+
def test_bytearray(self):
a = self.array('u', 'hi')
b = self.array('u')
@@ -940,15 +925,13 @@
assert repr(a) == "array('u', {!r})".format(s)
assert eval(repr(a), {'array': self.array}) == a
-
class DontTestCPythonsOwnArray(BaseArrayTests):
-
def setup_class(cls):
import array
cls.array = array.array
import struct
cls.struct = struct
- cls.tempfile = str(py.test.ensuretemp('array').join('tmpfile'))
+ cls.tempfile = str(pytest.ensuretemp('array').join('tmpfile'))
cls.maxint = sys.maxint
@@ -961,7 +944,7 @@
return array.array
""")
cls.w_tempfile = cls.space.wrap(
- str(py.test.ensuretemp('array').join('tmpfile')))
+ str(pytest.ensuretemp('array').join('tmpfile')))
cls.w_maxint = cls.space.wrap(sys.maxint)
def test_buffer_info(self):
@@ -1028,11 +1011,11 @@
def test_getitem_only_ints(self):
class MyInt(object):
- def __init__(self, x):
- self.x = x
+ def __init__(self, x):
+ self.x = x
- def __int__(self):
- return self.x
+ def __int__(self):
+ return self.x
a = self.array('i', [1, 2, 3, 4, 5, 6])
raises(TypeError, "a[MyInt(0)]")
diff --git a/pypy/module/cpyext/test/test_arraymodule.py b/pypy/module/cpyext/test/test_arraymodule.py
--- a/pypy/module/cpyext/test/test_arraymodule.py
+++ b/pypy/module/cpyext/test/test_arraymodule.py
@@ -1,7 +1,5 @@
from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
-import py
-import sys
class AppTestArrayModule(AppTestCpythonExtensionBase):
enable_leak_checking = False
@@ -21,7 +19,7 @@
module = self.import_module(name='array')
arr = module.array('i', [1,2,3])
sum = 0
- for i in arr:
+ for i in arr:
sum += i
assert sum == 6
@@ -60,4 +58,3 @@
b'\x02\0\0\0'
b'\x03\0\0\0'
b'\x04\0\0\0')
-
diff --git a/pypy/module/marshal/interp_marshal.py b/pypy/module/marshal/interp_marshal.py
--- a/pypy/module/marshal/interp_marshal.py
+++ b/pypy/module/marshal/interp_marshal.py
@@ -6,7 +6,7 @@
Py_MARSHAL_VERSION = 2
- at unwrap_spec(w_version = WrappedDefault(Py_MARSHAL_VERSION))
+ at unwrap_spec(w_version=WrappedDefault(Py_MARSHAL_VERSION))
def dump(space, w_data, w_f, w_version):
"""Write the 'data' object into the open file 'f'."""
# XXX: before py3k, we special-cased W_File to use a more performant
@@ -22,7 +22,7 @@
finally:
writer.finished()
- at unwrap_spec(w_version = WrappedDefault(Py_MARSHAL_VERSION))
+ at unwrap_spec(w_version=WrappedDefault(Py_MARSHAL_VERSION))
def dumps(space, w_data, w_version):
"""Return the string that would have been written to a file
by dump(data, file)."""
@@ -221,10 +221,15 @@
def dump_w_obj(self, w_obj):
space = self.space
- if (space.type(w_obj).is_heaptype() and
- space.lookup(w_obj, "__buffer__") is None):
- w_err = space.wrap("only builtins can be marshaled")
- raise OperationError(space.w_ValueError, w_err)
+ if space.type(w_obj).is_heaptype():
+ try:
+ buf = space.buffer_w(w_obj)
+ except OperationError as e:
+ if not e.match(space, space.w_TypeError):
+ raise
+ self.raise_exc("unmarshallable object")
+ else:
+ w_obj = space.newbuffer(buf)
try:
self.put_w_obj(w_obj)
except rstackovf.StackOverflow:
diff --git a/pypy/module/marshal/test/test_marshal.py b/pypy/module/marshal/test/test_marshal.py
--- a/pypy/module/marshal/test/test_marshal.py
+++ b/pypy/module/marshal/test/test_marshal.py
@@ -2,6 +2,8 @@
class AppTestMarshal:
+ spaceconfig = {'usemodules': ['array']}
+
def setup_class(cls):
tmpfile = udir.join('AppTestMarshal.tmp')
cls.w_tmpfile = cls.space.wrap(str(tmpfile))
@@ -171,9 +173,20 @@
import marshal
types = (float, complex, int, tuple, list, dict, set, frozenset)
for cls in types:
+ print cls
class subtype(cls):
pass
- raises(ValueError, marshal.dumps, subtype)
+ exc = raises(ValueError, marshal.dumps, subtype)
+ assert str(exc.value) == 'unmarshallable object'
+ exc = raises(ValueError, marshal.dumps, subtype())
+ assert str(exc.value) == 'unmarshallable object'
+
+ def test_valid_subtypes(self):
+ import marshal
+ from array import array
+ class subtype(array):
+ pass
+ assert marshal.dumps(subtype('c', 'test')) == marshal.dumps(array('c', 'test'))
def test_bad_typecode(self):
import marshal
@@ -188,7 +201,8 @@
class AppTestSmallLong(AppTestMarshal):
- spaceconfig = {"objspace.std.withsmalllong": True}
+ spaceconfig = AppTestMarshal.spaceconfig.copy()
+ spaceconfig["objspace.std.withsmalllong"] = True
def setup_class(cls):
from pypy.interpreter import gateway
diff --git a/pypy/module/rctime/interp_time.py b/pypy/module/rctime/interp_time.py
--- a/pypy/module/rctime/interp_time.py
+++ b/pypy/module/rctime/interp_time.py
@@ -3,7 +3,7 @@
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import unwrap_spec
from rpython.rtyper.lltypesystem import lltype
-from rpython.rlib.rarithmetic import ovfcheck_float_to_int, intmask
+from rpython.rlib.rarithmetic import intmask
from rpython.rlib import rposix
from rpython.translator.tool.cbuild import ExternalCompilationInfo
import os
diff --git a/pypy/module/sys/version.py b/pypy/module/sys/version.py
--- a/pypy/module/sys/version.py
+++ b/pypy/module/sys/version.py
@@ -2,7 +2,6 @@
Version numbers exposed by PyPy through the 'sys' module.
"""
import os
-import re
from rpython.translator.platform import platform
from pypy.interpreter import gateway
diff --git a/pypy/objspace/std/callmethod.py b/pypy/objspace/std/callmethod.py
--- a/pypy/objspace/std/callmethod.py
+++ b/pypy/objspace/std/callmethod.py
@@ -11,7 +11,6 @@
"""
from pypy.interpreter import function
-from pypy.objspace.descroperation import object_getattribute
from rpython.rlib import jit
from pypy.objspace.std.mapdict import LOOKUP_METHOD_mapdict, \
LOOKUP_METHOD_mapdict_fill_cache_method
@@ -36,7 +35,6 @@
if space.config.objspace.std.withmapdict and not jit.we_are_jitted():
# mapdict has an extra-fast version of this function
- from pypy.objspace.std.mapdict import LOOKUP_METHOD_mapdict
if LOOKUP_METHOD_mapdict(f, nameindex, w_obj):
return
@@ -79,7 +77,7 @@
n_kwargs = (oparg >> 8) & 0xff
w_self = f.peekvalue(n_args + (2 * n_kwargs))
n = n_args + (w_self is not None)
-
+
if not n_kwargs:
w_callable = f.peekvalue(n_args + (2 * n_kwargs) + 1)
try:
@@ -98,7 +96,7 @@
key = f.space.str_w(w_key)
keywords[n_kwargs] = key
keywords_w[n_kwargs] = w_value
-
+
arguments = f.popvalues(n) # includes w_self if it is not None
args = f.argument_factory(arguments, keywords, keywords_w, None, None)
if w_self is None:
diff --git a/pypy/objspace/std/celldict.py b/pypy/objspace/std/celldict.py
--- a/pypy/objspace/std/celldict.py
+++ b/pypy/objspace/std/celldict.py
@@ -140,7 +140,7 @@
for key, cell in iterator()]
def clear(self, w_dict):
- iterator = self.unerase(w_dict.dstorage).clear()
+ self.unerase(w_dict.dstorage).clear()
self.mutated()
def popitem(self, w_dict):
diff --git a/pypy/objspace/std/complexobject.py b/pypy/objspace/std/complexobject.py
--- a/pypy/objspace/std/complexobject.py
+++ b/pypy/objspace/std/complexobject.py
@@ -1,4 +1,5 @@
-from pypy.interpreter import gateway
+import math
+
from pypy.interpreter.error import OperationError
from pypy.objspace.std import newformat
from pypy.objspace.std.intobject import W_IntObject
@@ -12,8 +13,6 @@
from rpython.rlib import jit, rcomplex
from rpython.rlib.rarithmetic import intmask, r_ulonglong
-import math
-
HASH_IMAG = 1000003
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
@@ -1,7 +1,6 @@
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
from pypy.objspace.std.register_all import register_all
-from pypy.objspace.std.noneobject import W_NoneObject
from pypy.objspace.std.stdtypedef import GetSetProperty, StdTypeDef
from pypy.objspace.std.stdtypedef import StdObjSpaceMultiMethod
from pypy.objspace.std.unicodeobject import unicode_to_decimal_w
diff --git a/pypy/objspace/std/dictmultiobject.py b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -1092,7 +1092,7 @@
w_clone.setup_iterator()
# spool until we have the same pos
while w_clone.pos < self.pos:
- w_obj = w_clone.next_entry()
+ w_clone.next_entry()
w_clone.pos += 1
stuff = [w_clone.next_entry() for i in range(w_clone.pos, w_clone.len)]
w_res = space.newlist(stuff)
diff --git a/pypy/objspace/std/dictproxyobject.py b/pypy/objspace/std/dictproxyobject.py
--- a/pypy/objspace/std/dictproxyobject.py
+++ b/pypy/objspace/std/dictproxyobject.py
@@ -1,7 +1,6 @@
-from pypy.objspace.std.model import registerimplementation, W_Object
-from pypy.objspace.std.register_all import register_all
-from pypy.objspace.std.dictmultiobject import W_DictMultiObject, create_iterator_classes
-from pypy.objspace.std.dictmultiobject import DictStrategy
+#from pypy.objspace.std.model import registerimplementation, W_Object
+#from pypy.objspace.std.register_all import register_all
+from pypy.objspace.std.dictmultiobject import DictStrategy, create_iterator_classes
from pypy.objspace.std.typeobject import unwrap_cell
from pypy.interpreter.error import OperationError, oefmt
@@ -9,7 +8,6 @@
class DictProxyStrategy(DictStrategy):
-
erase, unerase = rerased.new_erasing_pair("dictproxy")
erase = staticmethod(erase)
unerase = staticmethod(unerase)
@@ -52,7 +50,6 @@
w_type.dict_w[key] = w_value
def setdefault(self, w_dict, w_key, w_default):
- space = self.space
w_result = self.getitem(w_dict, w_key)
if w_result is not None:
return w_result
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
@@ -1,14 +1,15 @@
+import math
import operator
from pypy.interpreter.error import OperationError, oefmt
-from pypy.objspace.std import model, newformat
+from pypy.objspace.std import newformat
from pypy.objspace.std.floattype import float_typedef, W_AbstractFloatObject
from pypy.objspace.std.intobject import HASH_BITS, HASH_MODULUS
from pypy.objspace.std.multimethod import FailedToImplementArgs
from pypy.objspace.std.model import registerimplementation, W_Object
from pypy.objspace.std.register_all import register_all
+from pypy.objspace.std.longobject import W_LongObject, newlong_from_float
from pypy.objspace.std.noneobject import W_NoneObject
-from pypy.objspace.std.longobject import W_LongObject, newlong_from_float
from rpython.rlib.rarithmetic import (
LONG_BIT, intmask, ovfcheck_float_to_int, r_uint)
from rpython.rlib.rfloat import (
@@ -18,8 +19,6 @@
from rpython.rlib import rfloat
from rpython.tool.sourcetools import func_with_new_name
-
-import math
from pypy.objspace.std.intobject import W_IntObject
HASH_INF = 314159
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
@@ -5,12 +5,11 @@
translation this module uses rarithmetic.ovfcheck to explicitly check
for overflows, something CPython does not do anymore.
"""
-
import operator
import sys
from rpython.rlib import jit
-from rpython.rlib.objectmodel import instantiate, import_from_mixin, specialize
+from rpython.rlib.objectmodel import instantiate
from rpython.rlib.rarithmetic import (
LONG_BIT, intmask, is_valid_int, ovfcheck, r_longlong, r_uint,
string_to_int)
@@ -23,7 +22,6 @@
from pypy.interpreter import typedef
from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.buffer import Buffer
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import (
WrappedDefault, applevel, interp2app, interpindirect2app, unwrap_spec)
@@ -32,7 +30,6 @@
BINARY_OPS, CMP_OPS, COMMUTATIVE_OPS, IDTAG_INT)
from pypy.objspace.std.stdtypedef import StdTypeDef
-
SENTINEL = object()
HASH_BITS = 61 if sys.maxsize > 2 ** 31 - 1 else 31
@@ -40,7 +37,6 @@
class W_AbstractIntObject(W_Root):
-
__slots__ = ()
def is_w(self, space, w_other):
diff --git a/pypy/objspace/std/marshal_impl.py b/pypy/objspace/std/marshal_impl.py
--- a/pypy/objspace/std/marshal_impl.py
+++ b/pypy/objspace/std/marshal_impl.py
@@ -10,7 +10,7 @@
from pypy.interpreter.error import OperationError
from pypy.objspace.std.register_all import register_all
-from rpython.rlib.rarithmetic import LONG_BIT, r_longlong, r_uint, intmask
+from rpython.rlib.rarithmetic import LONG_BIT, r_longlong, r_uint
from pypy.objspace.std import model
from pypy.objspace.std.dictmultiobject import W_DictMultiObject
from pypy.interpreter.special import Ellipsis
@@ -200,7 +200,6 @@
register(TYPE_BINARY_COMPLEX, unmarshal_Complex_bin)
def marshal_w__Long(space, w_long, m):
- from rpython.rlib.rbigint import rbigint
from rpython.rlib.rarithmetic import r_ulonglong
m.start(TYPE_LONG)
SHIFT = 15
@@ -359,7 +358,6 @@
lng = u.atom_lng(tc)
res = [None] * lng
idx = 0
- space = u.space
while idx < lng:
res[idx] = unmarshal_str(u)
idx += 1
diff --git a/pypy/objspace/std/multimethod.py b/pypy/objspace/std/multimethod.py
--- a/pypy/objspace/std/multimethod.py
+++ b/pypy/objspace/std/multimethod.py
@@ -866,7 +866,6 @@
entryarray = CompressedArray(null_entry)
indexarray = self.mrdtable.indexarray
lst = self.mrdtable.list_of_types
- indexline = []
def compress(typesprefix, typesnum):
if len(typesprefix) == self.multimethod.arity:
diff --git a/pypy/objspace/std/newformat.py b/pypy/objspace/std/newformat.py
--- a/pypy/objspace/std/newformat.py
+++ b/pypy/objspace/std/newformat.py
@@ -466,7 +466,6 @@
if not got_align:
self._align = "="
i += 1
- start_i = i
self._width, i = _parse_int(self.space, spec, i, length)
if length != i and spec[i] == ",":
self._thousands_sep = True
@@ -584,7 +583,6 @@
return space.wrap(self._pad(string))
def _get_locale(self, tp):
- space = self.space
if tp == "n":
dec, thousands, grouping = rlocale.numeric_formatting()
elif self._thousands_sep:
@@ -681,12 +679,10 @@
grouping = self._loc_grouping
min_width = spec.n_min_width
grouping_state = 0
- count = 0
left = spec.n_digits
n_ts = len(self._loc_thousands)
need_separator = False
done = False
- groupings = len(grouping)
previous = 0
while True:
group = ord(grouping[grouping_state])
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -331,7 +331,6 @@
strdict=strdict, kwargs=kwargs)
def newset(self):
- from pypy.objspace.std.setobject import newset
return W_SetObject(self, None)
def newslice(self, w_start, w_end, w_step):
diff --git a/pypy/objspace/std/proxy_helpers.py b/pypy/objspace/std/proxy_helpers.py
--- a/pypy/objspace/std/proxy_helpers.py
+++ b/pypy/objspace/std/proxy_helpers.py
@@ -1,10 +1,8 @@
-
""" Some transparent helpers, put here because
of cyclic imports
"""
-from pypy.objspace.std.model import W_ANY, W_Object
-from pypy.interpreter import baseobjspace
+from pypy.objspace.std.model import W_ANY
from pypy.interpreter.argument import Arguments
from rpython.tool.sourcetools import func_with_new_name
@@ -24,7 +22,7 @@
def function(space, w_transparent_list, __args__):
args = __args__.prepend(space.wrap(op_name))
return space.call_args(w_transparent_list.w_controller, args)
-
+
function = func_with_new_name(function, mm.name)
mm.register(function, type_)
@@ -32,14 +30,14 @@
def function(space, w_transparent_list, *args_w):
args = Arguments(space, [space.wrap(op_name)] + list(args_w[:-1]) + args_w[-1])
return space.call_args(w_transparent_list.w_controller, args)
-
+
function = func_with_new_name(function, mm.name)
mm.register(function, type_, *([W_ANY] * (mm.arity - 1)))
def install_mm_trampoline(type_, mm, is_local):
classname = type_.__name__[2:]
mm_name, op_name = create_mm_names(classname, mm, is_local)
-
+
if ['__args__'] == mm.argnames_after:
return install_general_args_trampoline(type_, mm, is_local, op_name)
if ['args_w'] == mm.argnames_after:
@@ -58,10 +56,10 @@
"""
if mm.arity != 2:
return False
-
+
if len(mm.specialnames) != 2:
return False
-
+
# search over the signatures
for signature in mm.signatures():
if signature == (type_.original, type_.original):
@@ -69,21 +67,21 @@
return False
def install_mm_special(type_, mm, is_local):
- classname = type_.__name__[2:]
+ #classname = type_.__name__[2:]
#mm_name, op_name = create_mm_names(classname, mm, is_local)
-
+
def function(space, w_any, w_transparent_list):
retval = space.call_function(w_transparent_list.w_controller, space.wrap(mm.specialnames[1]),
w_any)
return retval
-
+
function = func_with_new_name(function, mm.specialnames[0])
-
+
mm.register(function, type_.typedef.any, type_)
def register_type(type_):
from pypy.objspace.std.stdtypedef import multimethods_defined_on
-
+
for mm, is_local in multimethods_defined_on(type_.original):
if not mm.name.startswith('__'):
install_mm_trampoline(type_, mm, is_local)
diff --git a/pypy/objspace/std/proxyobject.py b/pypy/objspace/std/proxyobject.py
--- a/pypy/objspace/std/proxyobject.py
+++ b/pypy/objspace/std/proxyobject.py
@@ -1,15 +1,8 @@
-
""" transparent list implementation
"""
-
-from pypy.objspace.std.model import W_Object
from pypy.interpreter.error import OperationError
from pypy.interpreter import baseobjspace
-#class W_Transparent(W_Object):
-# def __init__(self, w_controller):
-# self.controller = w_controller
-
def transparent_class(name, BaseCls):
class W_Transparent(BaseCls):
@@ -72,25 +65,3 @@
return W_Transparent
W_Transparent = transparent_class('W_Transparent', baseobjspace.W_Root)
-#W_TransparentObject = transparent_class('W_TransparentObject', W_Object)
-
-#from pypy.objspace.std.objecttype import object_typedef
-#W_TransparentObject.typedef = object_typedef
-
-from pypy.interpreter.typedef import Function, GeneratorIterator, PyTraceback, \
- PyFrame, PyCode
-
-class W_TransparentFunction(W_Transparent):
- typedef = Function.typedef
-
-class W_TransparentTraceback(W_Transparent):
- typedef = PyTraceback.typedef
-
-class W_TransparentCode(W_Transparent):
- typedef = PyCode.typedef
-
-class W_TransparentFrame(W_Transparent):
- typedef = PyFrame.typedef
-
-class W_TransparentGenerator(W_Transparent):
- typedef = GeneratorIterator.typedef
diff --git a/pypy/objspace/std/slicetype.py b/pypy/objspace/std/slicetype.py
--- a/pypy/objspace/std/slicetype.py
+++ b/pypy/objspace/std/slicetype.py
@@ -1,4 +1,4 @@
-from pypy.interpreter import baseobjspace, gateway
+from pypy.interpreter import gateway
from pypy.interpreter.typedef import GetSetProperty
from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
from pypy.objspace.std.register_all import register_all
diff --git a/pypy/objspace/std/stdtypedef.py b/pypy/objspace/std/stdtypedef.py
--- a/pypy/objspace/std/stdtypedef.py
+++ b/pypy/objspace/std/stdtypedef.py
@@ -1,8 +1,7 @@
-from pypy.interpreter import gateway, baseobjspace, argument
+from pypy.interpreter import gateway, baseobjspace
from pypy.interpreter.error import OperationError, oefmt
-from pypy.interpreter.typedef import TypeDef, GetSetProperty, Member
-from pypy.interpreter.typedef import descr_get_dict, descr_set_dict
-from pypy.interpreter.typedef import descr_del_dict
+from pypy.interpreter.typedef import TypeDef, GetSetProperty, \
+ descr_get_dict, descr_set_dict, descr_del_dict
from pypy.interpreter.baseobjspace import SpaceCache
from pypy.objspace.std import model
from pypy.objspace.std.model import StdObjSpaceMultiMethod
diff --git a/pypy/objspace/std/stringmethods.py b/pypy/objspace/std/stringmethods.py
--- a/pypy/objspace/std/stringmethods.py
+++ b/pypy/objspace/std/stringmethods.py
@@ -446,7 +446,6 @@
def descr_split(self, space, w_sep=None, maxsplit=-1):
res = []
value = self._val(space)
- length = len(value)
if space.is_none(w_sep):
res = split(value, maxsplit=maxsplit)
return self._newlist_unwrapped(space, res)
diff --git a/pypy/objspace/std/transparent.py b/pypy/objspace/std/transparent.py
--- a/pypy/objspace/std/transparent.py
+++ b/pypy/objspace/std/transparent.py
@@ -1,14 +1,30 @@
-
""" transparent.py - Several transparent proxy helpers
"""
-
from pypy.interpreter import gateway
from pypy.interpreter.error import OperationError, oefmt
-from pypy.objspace.std.proxyobject import *
+from pypy.interpreter.typedef import Function, GeneratorIterator, PyTraceback, \
+ PyFrame, PyCode
+from pypy.objspace.std.proxyobject import W_Transparent
from pypy.objspace.std.typeobject import W_TypeObject
-from rpython.rlib.objectmodel import r_dict
from rpython.rlib.unroll import unrolling_iterable
+
+class W_TransparentFunction(W_Transparent):
+ typedef = Function.typedef
+
+class W_TransparentTraceback(W_Transparent):
+ typedef = PyTraceback.typedef
+
+class W_TransparentCode(W_Transparent):
+ typedef = PyCode.typedef
+
+class W_TransparentFrame(W_Transparent):
+ typedef = PyFrame.typedef
+
+class W_TransparentGenerator(W_Transparent):
+ typedef = GeneratorIterator.typedef
+
+
class TypeCache(object):
def __init__(self):
self.cache = []
@@ -28,13 +44,10 @@
space.wrap(app_proxy_controller))
-
def proxy(space, w_type, w_controller):
"""tproxy(typ, controller) -> obj
Return something that looks like it is of type typ. Its behaviour is
completely controlled by the controller."""
- from pypy.interpreter.typedef import Function, PyTraceback, PyFrame, \
- PyCode, GeneratorIterator
if not space.is_true(space.callable(w_controller)):
raise OperationError(space.w_TypeError, space.wrap("controller should be function"))
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -2,12 +2,12 @@
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.function import Function, StaticMethod
-from pypy.interpreter.typedef import weakref_descr, GetSetProperty,\
+from pypy.interpreter.typedef import weakref_descr, GetSetProperty, Member, \
descr_get_dict
from pypy.interpreter.astcompiler.misc import mangle
from pypy.objspace.std.model import W_Object
from pypy.objspace.std.register_all import register_all
-from pypy.objspace.std.stdtypedef import std_dict_descr, issubtypedef, Member
+from pypy.objspace.std.stdtypedef import std_dict_descr, issubtypedef
from pypy.objspace.std.stdtypedef import StdTypeDef
from rpython.rlib.jit import (promote, elidable_promote, we_are_jitted,
diff --git a/rpython/rlib/rfile.py b/rpython/rlib/rfile.py
--- a/rpython/rlib/rfile.py
+++ b/rpython/rlib/rfile.py
@@ -4,12 +4,12 @@
"""
import os
+from rpython.rlib import rposix
+from rpython.rlib.rarithmetic import intmask
+from rpython.rlib.rstring import StringBuilder
from rpython.rtyper.lltypesystem import rffi, lltype
from rpython.rtyper.tool import rffi_platform as platform
from rpython.translator.tool.cbuild import ExternalCompilationInfo
-from rpython.rlib.rarithmetic import r_uint, intmask
-from rpython.rlib import rposix
-from rpython.rlib.rstring import StringBuilder
includes = ['stdio.h', 'sys/types.h']
if os.name == "posix":
diff --git a/rpython/rlib/rwin32.py b/rpython/rlib/rwin32.py
--- a/rpython/rlib/rwin32.py
+++ b/rpython/rlib/rwin32.py
@@ -170,7 +170,7 @@
cfile.write(r'''
#include <errno.h>
#include <WinError.h>
- #include <stdio.h>
+ #include <stdio.h>
#ifdef __GNUC__
#define _dosmaperr mingw_dosmaperr
#endif
@@ -197,6 +197,7 @@
standalone=True)
except (CompilationError, WindowsError):
# Fallback for the mingw32 compiler
+ assert static_platform.name == 'mingw32'
errors = {
2: 2, 3: 2, 4: 24, 5: 13, 6: 9, 7: 12, 8: 12, 9: 12, 10: 7,
11: 8, 15: 2, 16: 13, 17: 18, 18: 2, 19: 13, 20: 13, 21: 13,
More information about the pypy-commit
mailing list