Author: Ronan Lamy <[email protected]>
Branch: py3.5
Changeset: r91709:78dee6627756
Date: 2017-07-06 18:18 +0100
http://bitbucket.org/pypy/pypy/changeset/78dee6627756/
Log: Ensure that mappingproxy is recognised as a mapping, not a sequence
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
@@ -93,3 +93,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,8 @@
self.w_text = self.w_str
del self.w_str
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['str'] = self.w_unicode
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
@@ -65,6 +65,7 @@
raises(TypeError, "proxy['a'] = 4")
raises(TypeError, "del proxy['a']")
raises(AttributeError, "proxy.clear()")
+ raises(TypeError, reversed, proxy)
#
class D(dict):
def copy(self): return 3
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit