[pypy-commit] pypy default: Merge heads
ademan
noreply at buildbot.pypy.org
Mon Jul 4 09:32:46 CEST 2011
Author: Daniel Roberts <Ademan555 at gmail.com>
Branch:
Changeset: r45331:710e095018ab
Date: 2011-07-04 00:40 -0700
http://bitbucket.org/pypy/pypy/changeset/710e095018ab/
Log: Merge heads
diff --git a/lib-python/modified-2.7/test/test_descr.py b/lib-python/modified-2.7/test/test_descr.py
--- a/lib-python/modified-2.7/test/test_descr.py
+++ b/lib-python/modified-2.7/test/test_descr.py
@@ -4400,7 +4400,10 @@
self.assertTrue(l.__add__ != l.__mul__)
self.assertTrue(l.__add__.__name__ == '__add__')
self.assertTrue(l.__add__.__self__ is l)
- self.assertTrue(l.__add__.__objclass__ is list)
+ if hasattr(l.__add__, '__objclass__'): # CPython
+ self.assertTrue(l.__add__.__objclass__ is list)
+ else: # PyPy
+ self.assertTrue(l.__add__.im_class is list)
self.assertEqual(l.__add__.__doc__, list.__add__.__doc__)
try:
hash(l.__add__)
diff --git a/lib_pypy/pwd.py b/lib_pypy/pwd.py
--- a/lib_pypy/pwd.py
+++ b/lib_pypy/pwd.py
@@ -16,6 +16,7 @@
from ctypes_support import standard_c_lib as libc
from ctypes import Structure, POINTER, c_int, c_char_p, c_long
+from _structseq import structseqtype, structseqfield
try: from __pypy__ import builtinify
except ImportError: builtinify = lambda f: f
@@ -68,7 +69,7 @@
yield self.pw_dir
yield self.pw_shell
-class struct_passwd(tuple):
+class struct_passwd:
"""
pwd.struct_passwd: Results from getpw*() routines.
@@ -76,15 +77,15 @@
(pw_name,pw_passwd,pw_uid,pw_gid,pw_gecos,pw_dir,pw_shell)
or via the object attributes as named in the above tuple.
"""
- def __init__(self, passwd):
- self.pw_name = passwd.pw_name
- self.pw_passwd = passwd.pw_passwd
- self.pw_uid = passwd.pw_uid
- self.pw_gid = passwd.pw_gid
- self.pw_gecos = passwd.pw_gecos
- self.pw_dir = passwd.pw_dir
- self.pw_shell = passwd.pw_shell
- tuple.__init__(self, passwd)
+ __metaclass__ = structseqtype
+ name = "pwd.struct_passwd"
+ pw_name = structseqfield(0)
+ pw_passwd = structseqfield(1)
+ pw_uid = structseqfield(2)
+ pw_gid = structseqfield(3)
+ pw_gecos = structseqfield(4)
+ pw_dir = structseqfield(5)
+ pw_shell = structseqfield(6)
passwd_p = POINTER(passwd)
diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -465,19 +465,23 @@
space.abstract_isinstance_w(w_firstarg, self.w_class)):
pass # ok
else:
- myname = self.getname(space,"")
- clsdescr = self.w_class.getname(space,"")
+ myname = self.getname(space, "")
+ clsdescr = self.w_class.getname(space, "")
if clsdescr:
- clsdescr+=" "
+ clsdescr += " instance"
+ else:
+ clsdescr = "instance"
if w_firstarg is None:
instdescr = "nothing"
else:
- instname = space.abstract_getclass(w_firstarg).getname(space,"")
+ instname = space.abstract_getclass(w_firstarg).getname(space,
+ "")
if instname:
- instname += " "
- instdescr = "%sinstance" %instname
- msg = ("unbound method %s() must be called with %s"
- "instance as first argument (got %s instead)")
+ instdescr = instname + " instance"
+ else:
+ instdescr = "instance"
+ msg = ("unbound method %s() must be called with %s "
+ "as first argument (got %s instead)")
raise operationerrfmt(space.w_TypeError, msg,
myname, clsdescr, instdescr)
return space.call_args(self.w_function, args)
diff --git a/pypy/interpreter/test/test_executioncontext.py b/pypy/interpreter/test/test_executioncontext.py
--- a/pypy/interpreter/test/test_executioncontext.py
+++ b/pypy/interpreter/test/test_executioncontext.py
@@ -106,7 +106,7 @@
if isinstance(seen[0], Method):
found = 'method %s of %s' % (
seen[0].w_function.name,
- seen[0].w_class.getname(space, '?'))
+ seen[0].w_class.getname(space))
else:
assert isinstance(seen[0], Function)
found = 'builtin %s' % seen[0].name
diff --git a/pypy/interpreter/test/test_typedef.py b/pypy/interpreter/test/test_typedef.py
--- a/pypy/interpreter/test/test_typedef.py
+++ b/pypy/interpreter/test/test_typedef.py
@@ -210,10 +210,20 @@
def m(self):
"aaa"
m.x = 3
+ class B(A):
+ pass
- bm = A().m
+ bm = B().m
assert bm.__func__ is bm.im_func
assert bm.__self__ is bm.im_self
+ assert bm.im_class is B
assert bm.__doc__ == "aaa"
assert bm.x == 3
raises(AttributeError, setattr, bm, 'x', 15)
+ l = []
+ assert l.append.__self__ is l
+ assert l.__add__.__self__ is l
+ # note: 'l.__add__.__objclass__' is not defined in pypy
+ # because it's a regular method, and .__objclass__
+ # differs from .im_class in case the method is
+ # defined in some parent class of l's actual class
diff --git a/pypy/jit/metainterp/optimizeopt/__init__.py b/pypy/jit/metainterp/optimizeopt/__init__.py
--- a/pypy/jit/metainterp/optimizeopt/__init__.py
+++ b/pypy/jit/metainterp/optimizeopt/__init__.py
@@ -3,7 +3,7 @@
from pypy.jit.metainterp.optimizeopt.intbounds import OptIntBounds
from pypy.jit.metainterp.optimizeopt.virtualize import OptVirtualize
from pypy.jit.metainterp.optimizeopt.heap import OptHeap
-from pypy.jit.metainterp.optimizeopt.string import OptString
+from pypy.jit.metainterp.optimizeopt.vstring import OptString
from pypy.jit.metainterp.optimizeopt.unroll import optimize_unroll, OptInlineShortPreamble
from pypy.jit.metainterp.optimizeopt.fficall import OptFfiCall
from pypy.jit.metainterp.optimizeopt.simplify import OptSimplify
@@ -21,15 +21,14 @@
unroll_all_opts = unrolling_iterable(ALL_OPTS)
ALL_OPTS_DICT = dict.fromkeys([name for name, _ in ALL_OPTS])
-
+ALL_OPTS_LIST = [name for name, _ in ALL_OPTS]
ALL_OPTS_NAMES = ':'.join([name for name, _ in ALL_OPTS])
-PARAMETERS['enable_opts'] = ALL_OPTS_NAMES
def build_opt_chain(metainterp_sd, enable_opts,
inline_short_preamble=True, retraced=False):
config = metainterp_sd.config
optimizations = []
- unroll = 'unroll' in enable_opts
+ unroll = 'unroll' in enable_opts # 'enable_opts' is normally a dict
for name, opt in unroll_all_opts:
if name in enable_opts:
if opt is not None:
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -4140,7 +4140,6 @@
# ----------
def optimize_strunicode_loop_extradescrs(self, ops, optops):
- from pypy.jit.metainterp.optimizeopt import string
class FakeCallInfoCollection:
def callinfo_for_oopspec(self, oopspecindex):
calldescrtype = type(LLtypeMixin.strequaldescr)
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -5373,7 +5373,6 @@
# ----------
def optimize_strunicode_loop_extradescrs(self, ops, optops, preamble=None):
- from pypy.jit.metainterp.optimizeopt import string
class FakeCallInfoCollection:
def callinfo_for_oopspec(self, oopspecindex):
calldescrtype = type(LLtypeMixin.strequaldescr)
diff --git a/pypy/jit/metainterp/optimizeopt/string.py b/pypy/jit/metainterp/optimizeopt/vstring.py
rename from pypy/jit/metainterp/optimizeopt/string.py
rename to pypy/jit/metainterp/optimizeopt/vstring.py
diff --git a/pypy/jit/metainterp/warmstate.py b/pypy/jit/metainterp/warmstate.py
--- a/pypy/jit/metainterp/warmstate.py
+++ b/pypy/jit/metainterp/warmstate.py
@@ -237,7 +237,7 @@
d = {}
if NonConstant(False):
value = 'blah' # not a constant ''
- if value is None:
+ if value is None or value == 'all':
value = ALL_OPTS_NAMES
for name in value.split(":"):
if name:
diff --git a/pypy/module/__builtin__/interp_classobj.py b/pypy/module/__builtin__/interp_classobj.py
--- a/pypy/module/__builtin__/interp_classobj.py
+++ b/pypy/module/__builtin__/interp_classobj.py
@@ -12,7 +12,7 @@
def raise_type_err(space, argument, expected, w_obj):
- type_name = space.type(w_obj).getname(space, '?')
+ type_name = space.type(w_obj).getname(space)
raise operationerrfmt(space.w_TypeError,
"argument %s must be %s, not %s",
argument, expected, type_name)
diff --git a/pypy/module/_codecs/interp_codecs.py b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -186,7 +186,7 @@
text = u'\ufffd' * size
return space.newtuple([space.wrap(text), w_end])
else:
- typename = space.type(w_exc).getname(space, '?')
+ typename = space.type(w_exc).getname(space)
raise operationerrfmt(space.w_TypeError,
"don't know how to handle %s in error callback", typename)
@@ -207,7 +207,7 @@
pos += 1
return space.newtuple([space.wrap(builder.build()), w_end])
else:
- typename = space.type(w_exc).getname(space, '?')
+ typename = space.type(w_exc).getname(space)
raise operationerrfmt(space.w_TypeError,
"don't know how to handle %s in error callback", typename)
@@ -240,7 +240,7 @@
pos += 1
return space.newtuple([space.wrap(builder.build()), w_end])
else:
- typename = space.type(w_exc).getname(space, '?')
+ typename = space.type(w_exc).getname(space)
raise operationerrfmt(space.w_TypeError,
"don't know how to handle %s in error callback", typename)
diff --git a/pypy/module/_io/interp_bufferedio.py b/pypy/module/_io/interp_bufferedio.py
--- a/pypy/module/_io/interp_bufferedio.py
+++ b/pypy/module/_io/interp_bufferedio.py
@@ -175,7 +175,7 @@
return space.call_method(self.w_raw, "isatty")
def repr_w(self, space):
- typename = space.type(self).getname(space, '?')
+ typename = space.type(self).getname(space)
module = space.str_w(space.type(self).get_module())
try:
w_name = space.getattr(self, space.wrap("name"))
diff --git a/pypy/module/_io/interp_iobase.py b/pypy/module/_io/interp_iobase.py
--- a/pypy/module/_io/interp_iobase.py
+++ b/pypy/module/_io/interp_iobase.py
@@ -155,7 +155,7 @@
raise operationerrfmt(
space.w_IOError,
"peek() should have returned a bytes object, "
- "not '%s'", space.type(w_readahead).getname(space, '?'))
+ "not '%s'", space.type(w_readahead).getname(space))
length = space.len_w(w_readahead)
if length > 0:
n = 0
@@ -181,7 +181,7 @@
raise operationerrfmt(
space.w_IOError,
"peek() should have returned a bytes object, "
- "not '%s'", space.type(w_read).getname(space, '?'))
+ "not '%s'", space.type(w_read).getname(space))
read = space.str_w(w_read)
if not read:
break
diff --git a/pypy/module/_io/interp_stringio.py b/pypy/module/_io/interp_stringio.py
--- a/pypy/module/_io/interp_stringio.py
+++ b/pypy/module/_io/interp_stringio.py
@@ -129,7 +129,7 @@
if not space.isinstance_w(w_obj, space.w_unicode):
raise operationerrfmt(space.w_TypeError,
"string argument expected, got '%s'",
- space.type(w_obj).getname(space, '?'))
+ space.type(w_obj).getname(space))
self._check_closed(space)
orig_size = space.len_w(w_obj)
diff --git a/pypy/module/_lsprof/interp_lsprof.py b/pypy/module/_lsprof/interp_lsprof.py
--- a/pypy/module/_lsprof/interp_lsprof.py
+++ b/pypy/module/_lsprof/interp_lsprof.py
@@ -212,7 +212,7 @@
module += '.'
return '{%s%s}' % (module, w_arg.name)
else:
- class_name = space.type(w_arg).getname(space, '?')
+ class_name = space.type(w_arg).getname(space)
return "{'%s' object}" % (class_name,)
def lsprof_call(space, w_self, frame, event, w_arg):
diff --git a/pypy/module/_multiprocessing/interp_connection.py b/pypy/module/_multiprocessing/interp_connection.py
--- a/pypy/module/_multiprocessing/interp_connection.py
+++ b/pypy/module/_multiprocessing/interp_connection.py
@@ -360,7 +360,7 @@
conn_type = ["read-only", "write-only", "read-write"][self.flags]
return space.wrap("<%s %s, handle %zd>" % (
- conn_type, space.type(self).getname(space, '?'), self.do_fileno()))
+ conn_type, space.type(self).getname(space), self.do_fileno()))
def is_valid(self):
return self.handle != self.INVALID_HANDLE_VALUE
diff --git a/pypy/module/_stackless/interp_coroutine.py b/pypy/module/_stackless/interp_coroutine.py
--- a/pypy/module/_stackless/interp_coroutine.py
+++ b/pypy/module/_stackless/interp_coroutine.py
@@ -40,7 +40,7 @@
raise operationerrfmt(
space.w_TypeError,
"'%s' object is not callable",
- space.type(w_obj).getname(space, '?'))
+ space.type(w_obj).getname(space))
self.w_func = w_obj
self.args = args
diff --git a/pypy/module/_weakref/interp__weakref.py b/pypy/module/_weakref/interp__weakref.py
--- a/pypy/module/_weakref/interp__weakref.py
+++ b/pypy/module/_weakref/interp__weakref.py
@@ -129,7 +129,7 @@
if w_obj is None:
state = '; dead'
else:
- typename = space.type(w_obj).getname(space, '?')
+ typename = space.type(w_obj).getname(space)
objname = w_obj.getname(space, '')
if objname:
state = "; to '%s' (%s)" % (typename, objname)
diff --git a/pypy/module/cpyext/methodobject.py b/pypy/module/cpyext/methodobject.py
--- a/pypy/module/cpyext/methodobject.py
+++ b/pypy/module/cpyext/methodobject.py
@@ -122,7 +122,7 @@
return self.space.unwrap(self.descr_method_repr())
def descr_method_repr(self):
- return self.getrepr(self.space, "built-in method '%s' of '%s' object" % (self.name, self.w_objclass.getname(self.space, '?')))
+ return self.getrepr(self.space, "built-in method '%s' of '%s' object" % (self.name, self.w_objclass.getname(self.space)))
PyCFunction_Check, PyCFunction_CheckExact = build_type_checkers("CFunction", W_PyCFunctionObject)
@@ -151,7 +151,7 @@
def descr_method_repr(self):
return self.space.wrap("<slot wrapper '%s' of '%s' objects>" % (self.method_name,
- self.w_objclass.getname(self.space, '?')))
+ self.w_objclass.getname(self.space)))
def cwrapper_descr_call(space, w_self, __args__):
self = space.interp_w(W_PyCWrapperObject, w_self)
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -450,7 +450,7 @@
PyObject_Del.api_func.get_wrapper(space))
pto.c_tp_alloc = llhelper(PyType_GenericAlloc.api_func.functype,
PyType_GenericAlloc.api_func.get_wrapper(space))
- pto.c_tp_name = rffi.str2charp(w_type.getname(space, "?"))
+ pto.c_tp_name = rffi.str2charp(w_type.getname(space))
pto.c_tp_basicsize = -1 # hopefully this makes malloc bail out
pto.c_tp_itemsize = 0
# uninitialized fields:
diff --git a/pypy/module/exceptions/interp_exceptions.py b/pypy/module/exceptions/interp_exceptions.py
--- a/pypy/module/exceptions/interp_exceptions.py
+++ b/pypy/module/exceptions/interp_exceptions.py
@@ -136,7 +136,7 @@
args_repr = space.str_w(space.repr(space.newtuple(self.args_w)))
else:
args_repr = "()"
- clsname = self.getclass(space).getname(space, '?')
+ clsname = self.getclass(space).getname(space)
return space.wrap(clsname + args_repr)
def descr_getargs(self, space):
@@ -546,7 +546,7 @@
w_tuple = space.newtuple(values_w + [self.w_lastlineno])
args_w = [self.args_w[0], w_tuple]
args_repr = space.str_w(space.repr(space.newtuple(args_w)))
- clsname = self.getclass(space).getname(space, '?')
+ clsname = self.getclass(space).getname(space)
return space.wrap(clsname + args_repr)
else:
return W_StandardError.descr_repr(self, space)
diff --git a/pypy/module/oracle/interp_variable.py b/pypy/module/oracle/interp_variable.py
--- a/pypy/module/oracle/interp_variable.py
+++ b/pypy/module/oracle/interp_variable.py
@@ -1484,7 +1484,7 @@
raise OperationError(
moduledict.w_NotSupportedError,
space.wrap("Variable_TypeByValue(): unhandled data type %s" %
- (space.type(w_value).getname(space, '?'),)))
+ (space.type(w_value).getname(space),)))
def newByInputTypeHandler(space, cursor, w_inputTypeHandler, w_value, numElements):
w_var = space.call(w_inputTypeHandler,
diff --git a/pypy/module/pyexpat/interp_pyexpat.py b/pypy/module/pyexpat/interp_pyexpat.py
--- a/pypy/module/pyexpat/interp_pyexpat.py
+++ b/pypy/module/pyexpat/interp_pyexpat.py
@@ -737,7 +737,7 @@
elif space.is_true(space.isinstance(w_encoding, space.w_str)):
encoding = space.str_w(w_encoding)
else:
- type_name = space.type(w_encoding).getname(space, '?')
+ type_name = space.type(w_encoding).getname(space)
raise OperationError(
space.w_TypeError,
space.wrap('ParserCreate() argument 1 must be string or None,'
@@ -757,7 +757,7 @@
space.wrap('namespace_separator must be at most one character,'
' omitted, or None'))
else:
- type_name = space.type(w_namespace_separator).getname(space, '?')
+ type_name = space.type(w_namespace_separator).getname(space)
raise OperationError(
space.w_TypeError,
space.wrap('ParserCreate() argument 2 must be string or None,'
diff --git a/pypy/module/pypyjit/interp_jit.py b/pypy/module/pypyjit/interp_jit.py
--- a/pypy/module/pypyjit/interp_jit.py
+++ b/pypy/module/pypyjit/interp_jit.py
@@ -176,6 +176,8 @@
'''Configure the tunable JIT parameters.
* set_param(name=value, ...) # as keyword arguments
* set_param("name=value,name=value") # as a user-supplied string
+ * set_param("off") # disable the jit
+ * set_param("default") # restore all defaults
'''
# XXXXXXXXX
args_w, kwds_w = __args__.unpack()
diff --git a/pypy/module/pypyjit/test/test_jit_setup.py b/pypy/module/pypyjit/test/test_jit_setup.py
--- a/pypy/module/pypyjit/test/test_jit_setup.py
+++ b/pypy/module/pypyjit/test/test_jit_setup.py
@@ -9,21 +9,42 @@
# this just checks that the module is setting up things correctly, and
# the resulting code makes sense on top of CPython.
import pypyjit
- pypyjit.set_param(threshold=5, inlining=1)
- pypyjit.set_param("trace_eagerness=3,inlining=0")
+ try:
+ pypyjit.set_param(threshold=5, inlining=1)
+ pypyjit.set_param("trace_eagerness=3,inlining=0")
- def f(x, y):
- return x*y+1
+ def f(x, y):
+ return x*y+1
- assert f(6, 7) == 43
+ assert f(6, 7) == 43
- def gen(x):
- i = 0
- while i < x:
- yield i*i
- i += 1
+ def gen(x):
+ i = 0
+ while i < x:
+ yield i*i
+ i += 1
- assert list(gen(3)) == [0, 1, 4]
+ assert list(gen(3)) == [0, 1, 4]
+ finally:
+ pypyjit.set_param('default')
+
+ def test_no_jit(self):
+ import pypyjit
+ was_called = []
+ def should_not_be_called(*args, **kwds):
+ was_called.append((args, kwds))
+ try:
+ pypyjit.set_param('off')
+ pypyjit.set_compile_hook(should_not_be_called)
+ def f():
+ pass
+ for i in range(2500):
+ f()
+ assert not was_called
+ finally:
+ pypyjit.set_compile_hook(None)
+ pypyjit.set_param('default')
+
def test_interface_residual_call():
space = gettestobjspace(usemodules=['pypyjit'])
diff --git a/pypy/module/test_lib_pypy/test_pwd.py b/pypy/module/test_lib_pypy/test_pwd.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/test_lib_pypy/test_pwd.py
@@ -0,0 +1,12 @@
+from pypy.conftest import gettestobjspace
+
+class AppTestPwd:
+ def setup_class(cls):
+ cls.space = gettestobjspace(usemodules=('_ffi', '_rawffi'))
+ cls.space.appexec((), "(): import pwd")
+
+ def test_getpwuid(self):
+ import os, pwd
+ passwd_info = pwd.getpwuid(os.getuid())
+ assert type(passwd_info).__name__ == 'struct_passwd'
+ assert repr(passwd_info).startswith("pwd.struct_passwd(pw_name=")
diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -416,7 +416,7 @@
# obscure circumstances.
return default_identity_hash(space, w_obj)
if space.is_w(w_hash, space.w_None):
- typename = space.type(w_obj).getname(space, '?')
+ typename = space.type(w_obj).getname(space)
raise operationerrfmt(space.w_TypeError,
"'%s' objects are unhashable", typename)
w_result = space.get_and_call_function(w_hash, w_obj)
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
@@ -374,7 +374,7 @@
raise operationerrfmt(
space.w_TypeError,
"sequence item %d: expected string, %s "
- "found", i, space.type(w_s).getname(space, '?'))
+ "found", i, space.type(w_s).getname(space))
if data and i != 0:
newdata.extend(data)
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
@@ -163,10 +163,7 @@
elif self.space.is_w(self.space.type(w_key), self.space.w_int):
self.switch_to_int_strategy(w_dict)
else:
- strategy = self.space.fromcache(ObjectDictStrategy)
- storage = strategy.get_empty_storage()
- w_dict.strategy = strategy
- w_dict.dstorage = storage
+ self.switch_to_object_strategy(w_dict)
def switch_to_string_strategy(self, w_dict):
strategy = self.space.fromcache(StringDictStrategy)
@@ -180,6 +177,12 @@
w_dict.strategy = strategy
w_dict.dstorage = storage
+ def switch_to_object_strategy(self, w_dict):
+ strategy = self.space.fromcache(ObjectDictStrategy)
+ storage = strategy.get_empty_storage()
+ w_dict.strategy = strategy
+ w_dict.dstorage = storage
+
def getitem(self, w_dict, w_key):
#return w_value or None
# in case the key is unhashable, try to hash it
@@ -817,7 +820,7 @@
def repr__DictViewKeys(space, w_dictview):
w_seq = space.call_function(space.w_list, w_dictview)
w_repr = space.repr(w_seq)
- return space.wrap("%s(%s)" % (space.type(w_dictview).getname(space, "?"),
+ return space.wrap("%s(%s)" % (space.type(w_dictview).getname(space),
space.str_w(w_repr)))
repr__DictViewItems = repr__DictViewKeys
repr__DictViewValues = repr__DictViewKeys
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -670,6 +670,8 @@
def popitem(self, w_dict):
curr = self.unerase(w_dict.dstorage)._get_mapdict_map().search(DICT)
+ if curr is None:
+ raise KeyError
key = curr.selector[0]
w_value = self.getitem_str(w_dict, key)
w_key = self.space.wrap(key)
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
@@ -255,7 +255,7 @@
w_result = self.wrap_exception_cls(x)
if w_result is not None:
return w_result
- from fake import fake_object
+ from pypy.objspace.std.fake import fake_object
return fake_object(self, x)
def wrap_exception_cls(self, x):
diff --git a/pypy/objspace/std/ropeunicodeobject.py b/pypy/objspace/std/ropeunicodeobject.py
--- a/pypy/objspace/std/ropeunicodeobject.py
+++ b/pypy/objspace/std/ropeunicodeobject.py
@@ -986,7 +986,7 @@
## return space.wrap(0)
## return space.wrap(result)
-import unicodetype
+from pypy.objspace.std import unicodetype
register_all(vars(), unicodetype)
# str.strip(unicode) needs to convert self to unicode and call unicode.strip we
@@ -997,7 +997,7 @@
# methods?
class str_methods:
- import stringtype
+ from pypy.objspace.std import stringtype
W_RopeUnicodeObject = W_RopeUnicodeObject
from pypy.objspace.std.ropeobject import W_RopeObject
def str_strip__Rope_RopeUnicode(space, w_self, w_chars):
diff --git a/pypy/objspace/std/test/test_celldict.py b/pypy/objspace/std/test/test_celldict.py
--- a/pypy/objspace/std/test/test_celldict.py
+++ b/pypy/objspace/std/test/test_celldict.py
@@ -43,6 +43,8 @@
OPTIONS = {"objspace.std.withcelldict": True}
def setup_class(cls):
+ if option.runappdirect:
+ py.test.skip("__repr__ doesn't work on appdirect")
strategy = ModuleDictStrategy(cls.space)
storage = strategy.get_empty_storage()
cls.w_d = W_DictMultiObject(cls.space, strategy, storage)
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -138,31 +138,31 @@
cls.w_on_pypy = cls.space.wrap("__pypy__" in sys.builtin_module_names)
def test_equality(self):
- d = {1:2}
- f = {1:2}
+ d = {1: 2}
+ f = {1: 2}
assert d == f
- assert d != {1:3}
+ assert d != {1: 3}
def test_clear(self):
- d = {1:2, 3:4}
+ d = {1: 2, 3: 4}
d.clear()
assert len(d) == 0
def test_copy(self):
- d = {1:2, 3:4}
+ d = {1: 2, 3: 4}
dd = d.copy()
assert d == dd
assert not d is dd
def test_get(self):
- d = {1:2, 3:4}
+ d = {1: 2, 3: 4}
assert d.get(1) == 2
- assert d.get(1,44) == 2
+ assert d.get(1, 44) == 2
assert d.get(33) == None
- assert d.get(33,44) == 44
+ assert d.get(33, 44) == 44
def test_pop(self):
- d = {1:2, 3:4}
+ d = {1: 2, 3: 4}
dd = d.copy()
result = dd.pop(1)
assert result == 2
@@ -177,18 +177,18 @@
raises(KeyError, dd.pop, 33)
def test_has_key(self):
- d = {1:2, 3:4}
+ d = {1: 2, 3: 4}
assert d.has_key(1)
assert not d.has_key(33)
def test_items(self):
- d = {1:2, 3:4}
+ d = {1: 2, 3: 4}
its = d.items()
its.sort()
- assert its == [(1,2),(3,4)]
+ assert its == [(1, 2), (3, 4)]
def test_iteritems(self):
- d = {1:2, 3:4}
+ d = {1: 2, 3: 4}
dd = d.copy()
for k, v in d.iteritems():
assert v == dd[k]
@@ -196,33 +196,33 @@
assert not dd
def test_iterkeys(self):
- d = {1:2, 3:4}
+ d = {1: 2, 3: 4}
dd = d.copy()
for k in d.iterkeys():
del dd[k]
assert not dd
def test_itervalues(self):
- d = {1:2, 3:4}
+ d = {1: 2, 3: 4}
values = []
for k in d.itervalues():
values.append(k)
assert values == d.values()
def test_keys(self):
- d = {1:2, 3:4}
+ d = {1: 2, 3: 4}
kys = d.keys()
kys.sort()
- assert kys == [1,3]
+ assert kys == [1, 3]
def test_popitem(self):
- d = {1:2, 3:4}
+ d = {1: 2, 3: 4}
it = d.popitem()
assert len(d) == 1
- assert it==(1,2) or it==(3,4)
+ assert it == (1, 2) or it == (3, 4)
it1 = d.popitem()
assert len(d) == 0
- assert (it!=it1) and (it1==(1,2) or it1==(3,4))
+ assert (it != it1) and (it1 == (1, 2) or it1 == (3, 4))
raises(KeyError, d.popitem)
def test_popitem_2(self):
@@ -236,16 +236,16 @@
def test_popitem3(self):
#object
- d = {"a": 1, 2:2, "c":3}
+ d = {"a": 1, 2: 2, "c": 3}
l = []
while True:
try:
l.append(d.popitem())
except KeyError:
break;
- assert ("a",1) in l
- assert (2,2) in l
- assert ("c",3) in l
+ assert ("a", 1) in l
+ assert (2, 2) in l
+ assert ("c", 3) in l
#string
d = {"a": 1, "b":2, "c":3}
@@ -255,12 +255,12 @@
l.append(d.popitem())
except KeyError:
break;
- assert ("a",1) in l
- assert ("b",2) in l
- assert ("c",3) in l
+ assert ("a", 1) in l
+ assert ("b", 2) in l
+ assert ("c", 3) in l
def test_setdefault(self):
- d = {1:2, 3:4}
+ d = {1: 2, 3: 4}
dd = d.copy()
x = dd.setdefault(1, 99)
assert d == dd
@@ -293,12 +293,12 @@
assert k.calls == 1
def test_update(self):
- d = {1:2, 3:4}
+ d = {1: 2, 3: 4}
dd = d.copy()
d.update({})
assert d == dd
- d.update({3:5, 6:7})
- assert d == {1:2, 3:5, 6:7}
+ d.update({3: 5, 6: 7})
+ assert d == {1: 2, 3: 5, 6: 7}
def test_update_iterable(self):
d = {}
@@ -323,15 +323,15 @@
assert d == {'foo': 'bar', 'baz': 1}
def test_values(self):
- d = {1:2, 3:4}
+ d = {1: 2, 3: 4}
vals = d.values()
vals.sort()
assert vals == [2,4]
def test_eq(self):
- d1 = {1:2, 3:4}
- d2 = {1:2, 3:4}
- d3 = {1:2}
+ d1 = {1: 2, 3: 4}
+ d2 = {1: 2, 3: 4}
+ d3 = {1: 2}
bool = d1 == d2
assert bool == True
bool = d1 == d3
@@ -342,10 +342,10 @@
assert bool == True
def test_lt(self):
- d1 = {1:2, 3:4}
- d2 = {1:2, 3:4}
- d3 = {1:2, 3:5}
- d4 = {1:2}
+ d1 = {1: 2, 3: 4}
+ d2 = {1: 2, 3: 4}
+ d3 = {1: 2, 3: 5}
+ d4 = {1: 2}
bool = d1 < d2
assert bool == False
bool = d1 < d3
@@ -392,21 +392,17 @@
def test_new(self):
d = dict()
assert d == {}
- args = [['a',2], [23,45]]
+ args = [['a', 2], [23, 45]]
d = dict(args)
- assert d == {'a':2, 23:45}
+ assert d == {'a': 2, 23: 45}
d = dict(args, a=33, b=44)
- assert d == {'a':33, 'b':44, 23:45}
+ assert d == {'a': 33, 'b': 44, 23: 45}
d = dict(a=33, b=44)
- assert d == {'a':33, 'b':44}
- d = dict({'a':33, 'b':44})
- assert d == {'a':33, 'b':44}
- try: d = dict(23)
- except (TypeError, ValueError): pass
- else: self.fail("dict(23) should raise!")
- try: d = dict([[1,2,3]])
- except (TypeError, ValueError): pass
- else: self.fail("dict([[1,2,3]]) should raise!")
+ assert d == {'a': 33, 'b': 44}
+ d = dict({'a': 33, 'b': 44})
+ assert d == {'a': 33, 'b': 44}
+ raises((TypeError, ValueError), dict, 23)
+ raises((TypeError, ValueError), dict, [[1, 2, 3]])
def test_fromkeys(self):
assert {}.fromkeys([1, 2], 1) == {1: 1, 2: 1}
diff --git a/pypy/objspace/std/test/test_mapdict.py b/pypy/objspace/std/test/test_mapdict.py
--- a/pypy/objspace/std/test/test_mapdict.py
+++ b/pypy/objspace/std/test/test_mapdict.py
@@ -479,6 +479,7 @@
it2 = a.__dict__.popitem()
assert it2 == ("x", 5)
assert a.__dict__ == {}
+ raises(KeyError, a.__dict__.popitem)
@@ -622,6 +623,14 @@
assert a.__dict__ is d
assert isinstance(a, B)
+ def test_setdict(self):
+ class A(object):
+ pass
+
+ a = A()
+ a.__dict__ = {}
+ a.__dict__ = {}
+
class AppTestWithMapDictAndCounters(object):
def setup_class(cls):
diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -937,7 +937,7 @@
return formatter.format_string(space.unicode_w(w_unicode))
-import unicodetype
+from pypy.objspace.std import unicodetype
register_all(vars(), unicodetype)
# str.strip(unicode) needs to convert self to unicode and call unicode.strip we
@@ -948,7 +948,7 @@
# methods?
class str_methods:
- import stringtype
+ from pypy.objspace.std import stringtype
W_UnicodeObject = W_UnicodeObject
from pypy.objspace.std.stringobject import W_StringObject
from pypy.objspace.std.ropeobject import W_RopeObject
diff --git a/pypy/objspace/taint.py b/pypy/objspace/taint.py
--- a/pypy/objspace/taint.py
+++ b/pypy/objspace/taint.py
@@ -92,8 +92,8 @@
w_realtype = space.type(w_obj)
if not space.is_w(w_realtype, w_expectedtype):
#msg = "expected an object of type '%s'" % (
- # w_expectedtype.getname(space, '?'),)
- # #w_realtype.getname(space, '?'))
+ # w_expectedtype.getname(space),)
+ # #w_realtype.getname(space))
raise OperationError(space.w_TaintError, space.w_None)
return w_obj
app_untaint = gateway.interp2app(untaint)
diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py
--- a/pypy/rlib/jit.py
+++ b/pypy/rlib/jit.py
@@ -292,12 +292,13 @@
'function_threshold': 1617, # slightly more than one above
'trace_eagerness': 200,
'trace_limit': 12000,
- 'inlining': 0,
+ 'inlining': 1,
'loop_longevity': 1000,
'retrace_limit': 5,
- 'enable_opts': None, # patched later by optimizeopt/__init__.py
+ 'enable_opts': 'all',
}
unroll_parameters = unrolling_iterable(PARAMETERS.items())
+DEFAULT = object()
# ____________________________________________________________
@@ -352,22 +353,33 @@
def _set_param(self, name, value):
# special-cased by ExtRegistryEntry
# (internal, must receive a constant 'name')
+ # if value is DEFAULT, sets the default value.
assert name in PARAMETERS
@specialize.arg(0, 1)
def set_param(self, name, value):
"""Set one of the tunable JIT parameter."""
- for name1, _ in unroll_parameters:
- if name1 == name:
- self._set_param(name1, value)
- return
- raise ValueError("no such parameter")
+ self._set_param(name, value)
+
+ @specialize.arg(0, 1)
+ def set_param_to_default(self, name):
+ """Reset one of the tunable JIT parameters to its default value."""
+ self._set_param(name, DEFAULT)
def set_user_param(self, text):
"""Set the tunable JIT parameters from a user-supplied string
- following the format 'param=value,param=value'. For programmatic
- setting of parameters, use directly JitDriver.set_param().
+ following the format 'param=value,param=value', or 'off' to
+ disable the JIT. For programmatic setting of parameters, use
+ directly JitDriver.set_param().
"""
+ if text == 'off':
+ self.set_param('threshold', -1)
+ self.set_param('function_threshold', -1)
+ return
+ if text == 'default':
+ for name1, _ in unroll_parameters:
+ self.set_param_to_default(name1)
+ return
for s in text.split(','):
s = s.strip(' ')
parts = s.split('=')
@@ -590,15 +602,17 @@
def compute_result_annotation(self, s_name, s_value):
from pypy.annotation import model as annmodel
assert s_name.is_constant()
- if s_name.const == 'enable_opts':
- assert annmodel.SomeString(can_be_None=True).contains(s_value)
- else:
- assert annmodel.SomeInteger().contains(s_value)
+ if not self.bookkeeper.immutablevalue(DEFAULT).contains(s_value):
+ if s_name.const == 'enable_opts':
+ assert annmodel.SomeString(can_be_None=True).contains(s_value)
+ else:
+ assert annmodel.SomeInteger().contains(s_value)
return annmodel.s_None
def specialize_call(self, hop):
from pypy.rpython.lltypesystem import lltype
from pypy.rpython.lltypesystem.rstr import string_repr
+ from pypy.objspace.flow.model import Constant
hop.exception_cannot_occur()
driver = self.instance.im_self
@@ -607,7 +621,12 @@
repr = string_repr
else:
repr = lltype.Signed
- v_value = hop.inputarg(repr, arg=1)
+ if (isinstance(hop.args_v[1], Constant) and
+ hop.args_v[1].value is DEFAULT):
+ value = PARAMETERS[name]
+ v_value = hop.inputconst(repr, value)
+ else:
+ v_value = hop.inputarg(repr, arg=1)
vlist = [hop.inputconst(lltype.Void, "set_param"),
hop.inputconst(lltype.Void, driver),
hop.inputconst(lltype.Void, name),
diff --git a/pypy/tool/pytest/appsupport.py b/pypy/tool/pytest/appsupport.py
--- a/pypy/tool/pytest/appsupport.py
+++ b/pypy/tool/pytest/appsupport.py
@@ -83,7 +83,7 @@
def __init__(self, space, operr):
self.space = space
self.operr = operr
- self.typename = operr.w_type.getname(space, "?")
+ self.typename = operr.w_type.getname(space)
self.traceback = AppTraceback(space, self.operr.get_traceback())
debug_excs = getattr(operr, 'debug_excs', [])
if debug_excs:
diff --git a/pypy/translator/goal/app_main.py b/pypy/translator/goal/app_main.py
--- a/pypy/translator/goal/app_main.py
+++ b/pypy/translator/goal/app_main.py
@@ -143,6 +143,7 @@
for key, value in items:
print ' --jit %s=N %slow-level JIT parameter (default %s)' % (
key, ' '*(18-len(key)), value)
+ print ' --jit off turn off the JIT'
def print_version(*args):
print "Python", sys.version
More information about the pypy-commit
mailing list