[pypy-commit] pypy stdlib-2.7.8: hack partial so test_functools passes
bdkearns
noreply at buildbot.pypy.org
Sun Aug 24 23:50:49 CEST 2014
Author: Brian Kearns <bdkearns at gmail.com>
Branch: stdlib-2.7.8
Changeset: r73053:f3332cf0c172
Date: 2014-08-24 17:50 -0400
http://bitbucket.org/pypy/pypy/changeset/f3332cf0c172/
Log: hack partial so test_functools passes
diff --git a/lib_pypy/_functools.py b/lib_pypy/_functools.py
--- a/lib_pypy/_functools.py
+++ b/lib_pypy/_functools.py
@@ -16,6 +16,11 @@
self._args = args
self._keywords = keywords or None
+ def __delattr__(self, key):
+ if key == '__dict__':
+ raise TypeError("a partial object's dictionary may not be deleted")
+ object.__delattr__(self, key)
+
@property
def func(self):
return self._func
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
@@ -25,3 +25,8 @@
partial = _functools.partial(object)
with pytest.raises((TypeError, AttributeError)):
partial.func = sum
+ with pytest.raises(TypeError) as exc:
+ del partial.__dict__
+ assert str(exc.value) == "a partial object's dictionary may not be deleted"
+ with pytest.raises(AttributeError):
+ del partial.zzz
More information about the pypy-commit
mailing list