[pypy-commit] pypy default: issue #2601
arigo
pypy.commits at gmail.com
Sat Jul 8 11:11:59 EDT 2017
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r91842:fe1c32761823
Date: 2017-07-08 17:10 +0200
http://bitbucket.org/pypy/pypy/changeset/fe1c32761823/
Log: issue #2601
Fix for 'reversed(dictproxy)', mostly by backporting 78dee66
diff --git a/pypy/module/__builtin__/test/test_functional.py b/pypy/module/__builtin__/test/test_functional.py
--- a/pypy/module/__builtin__/test/test_functional.py
+++ b/pypy/module/__builtin__/test/test_functional.py
@@ -239,6 +239,7 @@
raises(TypeError, reversed, {})
raises(TypeError, reversed, {2: 3})
assert not hasattr(dict, '__reversed__')
+ raises(TypeError, reversed, int.__dict__)
def test_reversed_type_with_no_len(self):
class X(object):
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
@@ -99,3 +99,7 @@
copy=interp2app(W_DictProxyObject.copy_w),
**cmp_methods
)
+
+def _set_flag_map_or_seq(space):
+ w_type = space.gettypeobject(W_DictProxyObject.typedef)
+ w_type.flag_map_or_seq = 'M'
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
@@ -96,6 +96,10 @@
self._interplevel_classes[w_type] = cls
self.w_text = self.w_bytes # 'space.w_text' is w_unicode on Py3
self.w_dict.flag_map_or_seq = 'M'
+ from pypy.objspace.std import dictproxyobject
+ dictproxyobject._set_flag_map_or_seq(self)
+ self.w_list.flag_map_or_seq = 'S'
+ self.w_tuple.flag_map_or_seq = 'S'
self.builtin_types["NotImplemented"] = self.w_NotImplemented
self.builtin_types["Ellipsis"] = self.w_Ellipsis
self.w_basestring = self.builtin_types['basestring'] = \
diff --git a/pypy/objspace/std/test/test_dictproxy.py b/pypy/objspace/std/test/test_dictproxy.py
--- a/pypy/objspace/std/test/test_dictproxy.py
+++ b/pypy/objspace/std/test/test_dictproxy.py
@@ -78,6 +78,8 @@
raises(TypeError, "proxy['a'] = 4")
raises(TypeError, "del proxy['a']")
raises(AttributeError, "proxy.clear()")
+ raises(TypeError, reversed, proxy)
+
class AppTestUserObjectMethodCache(AppTestUserObject):
spaceconfig = {"objspace.std.withmethodcachecounter": True}
More information about the pypy-commit
mailing list