[pypy-commit] pypy stdlib-2.7.8: merge heads
bdkearns
noreply at buildbot.pypy.org
Sat Aug 23 18:09:54 CEST 2014
Author: Brian Kearns <bdkearns at gmail.com>
Branch: stdlib-2.7.8
Changeset: r73002:f3300a7a8bc9
Date: 2014-08-23 12:09 -0400
http://bitbucket.org/pypy/pypy/changeset/f3300a7a8bc9/
Log: merge heads
diff --git a/lib-python/2.7/test/test_functools.py b/lib-python/2.7/test/test_functools.py
--- a/lib-python/2.7/test/test_functools.py
+++ b/lib-python/2.7/test/test_functools.py
@@ -43,9 +43,9 @@
self.assertEqual(p.args, (1, 2))
self.assertEqual(p.keywords, dict(a=10, b=20))
# attributes should not be writable
- self.assertRaises(TypeError, setattr, p, 'func', map)
- self.assertRaises(TypeError, setattr, p, 'args', (1, 2))
- self.assertRaises(TypeError, setattr, p, 'keywords', dict(a=1, b=2))
+ self.assertRaises((TypeError, AttributeError), setattr, p, 'func', map)
+ self.assertRaises((TypeError, AttributeError), setattr, p, 'args', (1, 2))
+ self.assertRaises((TypeError, AttributeError), setattr, p, 'keywords', dict(a=1, b=2))
p = self.thetype(hex)
try:
diff --git a/lib_pypy/_functools.py b/lib_pypy/_functools.py
--- a/lib_pypy/_functools.py
+++ b/lib_pypy/_functools.py
@@ -12,9 +12,21 @@
def __init__(self, func, *args, **keywords):
if not callable(func):
raise TypeError("the first argument must be callable")
- self.func = func
- self.args = args
- self.keywords = keywords or None
+ self._func = func
+ self._args = args
+ self._keywords = keywords or None
+
+ @property
+ def func(self):
+ return self._func
+
+ @property
+ def args(self):
+ return self._args
+
+ @property
+ def keywords(self):
+ return self._keywords
def __call__(self, *fargs, **fkeywords):
if self.keywords is not None:
@@ -23,13 +35,13 @@
def __reduce__(self):
d = dict((k, v) for k, v in self.__dict__.iteritems() if k not in
- ('func', 'args', 'keywords'))
+ ('_func', '_args', '_keywords'))
if len(d) == 0:
d = None
return (type(self), (self.func,),
(self.func, self.args, self.keywords, d))
def __setstate__(self, state):
- self.func, self.args, self.keywords, d = state
+ self._func, self._args, self._keywords, d = state
if d is not None:
self.__dict__.update(d)
diff --git a/pypy/interpreter/astcompiler/assemble.py b/pypy/interpreter/astcompiler/assemble.py
--- a/pypy/interpreter/astcompiler/assemble.py
+++ b/pypy/interpreter/astcompiler/assemble.py
@@ -406,6 +406,9 @@
target_depth += 3
if target_depth > self._max_depth:
self._max_depth = target_depth
+ elif (jump_op == ops.JUMP_IF_TRUE_OR_POP or
+ jump_op == ops.JUMP_IF_FALSE_OR_POP):
+ depth -= 1
self._next_stack_depth_walk(instr.jump[0], target_depth)
if jump_op == ops.JUMP_ABSOLUTE or jump_op == ops.JUMP_FORWARD:
# Nothing more can occur.
diff --git a/pypy/module/test_lib_pypy/test_functools.py b/pypy/module/test_lib_pypy/test_functools.py
--- a/pypy/module/test_lib_pypy/test_functools.py
+++ b/pypy/module/test_lib_pypy/test_functools.py
@@ -1,5 +1,8 @@
+import pytest
+
from lib_pypy import _functools
+
def test_partial_reduce():
partial = _functools.partial(test_partial_reduce)
state = partial.__reduce__()
@@ -17,3 +20,8 @@
string = pickle.dumps(partial1)
partial2 = pickle.loads(string)
assert partial1.func == partial2.func
+
+def test_immutable_attributes():
+ partial = _functools.partial(object)
+ with pytest.raises((TypeError, AttributeError)):
+ partial.func = sum
diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -200,8 +200,7 @@
# correct answer here!
def descr_lt(self, space, w_other):
if not isinstance(w_other, W_BaseSetObject):
- raise OperationError(self.space.w_TypeError,
- self.space.wrap('can only compare to a set'))
+ return space.w_NotImplemented
if self.length() >= w_other.length():
return space.w_False
@@ -210,8 +209,7 @@
def descr_le(self, space, w_other):
if not isinstance(w_other, W_BaseSetObject):
- raise OperationError(self.space.w_TypeError,
- self.space.wrap('can only compare to a set'))
+ return space.w_NotImplemented
if self.length() > w_other.length():
return space.w_False
@@ -219,8 +217,7 @@
def descr_gt(self, space, w_other):
if not isinstance(w_other, W_BaseSetObject):
- raise OperationError(self.space.w_TypeError,
- self.space.wrap('can only compare to a set'))
+ return space.w_NotImplemented
if self.length() <= w_other.length():
return space.w_False
@@ -229,8 +226,7 @@
def descr_ge(self, space, w_other):
if not isinstance(w_other, W_BaseSetObject):
- raise OperationError(self.space.w_TypeError,
- self.space.wrap('can only compare to a set'))
+ return space.w_NotImplemented
if self.length() < w_other.length():
return space.w_False
diff --git a/pypy/objspace/std/test/test_setobject.py b/pypy/objspace/std/test/test_setobject.py
--- a/pypy/objspace/std/test/test_setobject.py
+++ b/pypy/objspace/std/test/test_setobject.py
@@ -8,10 +8,8 @@
This file just contains some basic tests that make sure, the implementation
is not too wrong.
"""
-import py.test
from pypy.objspace.std.setobject import W_SetObject, W_FrozensetObject, IntegerSetStrategy
from pypy.objspace.std.setobject import _initialize_set
-from pypy.objspace.std.setobject import newset
from pypy.objspace.std.listobject import W_ListObject
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
More information about the pypy-commit
mailing list