[pypy-commit] pypy py3.5: hg merge default
arigo
pypy.commits at gmail.com
Wed Feb 1 09:09:49 EST 2017
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r89883:ae853aa08f40
Date: 2017-02-01 15:09 +0100
http://bitbucket.org/pypy/pypy/changeset/ae853aa08f40/
Log: hg merge default
diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -207,10 +207,16 @@
def getdict(self, space):
if self.w_func_dict is None:
+ if not self.can_change_code:
+ raise oefmt(space.w_AttributeError,
+ "cannot set extra attributes on built-in functions")
self.w_func_dict = space.newdict(instance=True)
return self.w_func_dict
def setdict(self, space, w_dict):
+ if not self.can_change_code:
+ raise oefmt(space.w_AttributeError,
+ "cannot set __dict__ on built-in functions")
if not space.isinstance_w(w_dict, space.w_dict):
raise oefmt(space.w_TypeError,
"setting function's dictionary to a non-dict")
@@ -695,7 +701,7 @@
func.defs_w, None, func.closure,
None, func.name)
self.w_doc = func.w_doc
- self.w_func_dict = func.w_func_dict
+ #self.w_func_dict = func.w_func_dict---nowadays, always None
self.w_module = func.w_module
self.w_kw_defs = func.w_kw_defs
diff --git a/pypy/interpreter/test/test_function.py b/pypy/interpreter/test/test_function.py
--- a/pypy/interpreter/test/test_function.py
+++ b/pypy/interpreter/test/test_function.py
@@ -160,10 +160,14 @@
def test_write_code_builtin_forbidden(self):
def f(*args):
return 42
- if hasattr('dir', '__code__'):
- # only on PyPy, CPython does not expose these attrs
- raises(TypeError, "dir.__code__ = f.__code__")
- raises(TypeError, "list().append.__func__.__code__ = f.__code__")
+ raises(TypeError, "dir.__code__ = f.__code__")
+ raises(TypeError, "list.append.__code__ = f.__code__")
+
+ def test_write_extra_attributes_builtin_forbidden(self):
+ raises(AttributeError, "dir.abcd = 5")
+ raises(AttributeError, "list.append.im_func.efgh = 6")
+ raises(AttributeError, "dir.__dict__")
+ raises(AttributeError, "dir.__dict__ = {}")
def test_set_module_to_name_eagerly(self):
skip("fails on PyPy but works on CPython. Unsure we want to care")
diff --git a/rpython/jit/codewriter/test/test_call.py b/rpython/jit/codewriter/test/test_call.py
--- a/rpython/jit/codewriter/test/test_call.py
+++ b/rpython/jit/codewriter/test/test_call.py
@@ -281,6 +281,8 @@
def test_elidable_kinds():
from rpython.jit.backend.llgraph.runner import LLGraphCPU
+ from rpython.rlib.objectmodel import compute_hash
+ from rpython.rlib.rsiphash import enable_siphash24
@jit.elidable
def f1(n, m):
@@ -293,12 +295,17 @@
if n > m:
raise ValueError
return n + m
+ @jit.elidable
+ def f4(n, m):
+ return compute_hash(str(n) + str(m))
def f(n, m):
a = f1(n, m)
b = f2(n, m)
c = f3(n, m)
- return a + len(b) + c
+ d = f4(n, m)
+ enable_siphash24()
+ return a + len(b) + c + d
rtyper = support.annotate(f, [7, 9])
jitdriver_sd = FakeJitDriverSD(rtyper.annotator.translator.graphs[0])
@@ -309,7 +316,8 @@
for index, expected in [
(0, EffectInfo.EF_ELIDABLE_CANNOT_RAISE),
(1, EffectInfo.EF_ELIDABLE_OR_MEMORYERROR),
- (2, EffectInfo.EF_ELIDABLE_CAN_RAISE)]:
+ (2, EffectInfo.EF_ELIDABLE_CAN_RAISE),
+ (3, EffectInfo.EF_ELIDABLE_OR_MEMORYERROR)]:
call_op = f_graph.startblock.operations[index]
assert call_op.opname == 'direct_call'
call_descr = cc.getcalldescr(call_op)
More information about the pypy-commit
mailing list