Author: Matti Picus <matti.pi...@gmail.com>
Branch: 
Changeset: r91626:6d81023ea3fe
Date: 2017-06-19 20:01 +0300
http://bitbucket.org/pypy/pypy/changeset/6d81023ea3fe/

Log:    make FrozenDict fail PySequence_Check() - fixes obscure numpy test
        failure

diff --git a/pypy/module/cpyext/dictobject.py b/pypy/module/cpyext/dictobject.py
--- a/pypy/module/cpyext/dictobject.py
+++ b/pypy/module/cpyext/dictobject.py
@@ -290,6 +290,7 @@
 def make_frozendict(space):
     if space not in _frozendict_cache:
         _frozendict_cache[space] = _make_frozendict(space)
+        _frozendict_cache[space].flag_map_or_seq = 'M'
     return _frozendict_cache[space]
 
 _frozendict_cache = {}
diff --git a/pypy/module/cpyext/test/test_iterator.py 
b/pypy/module/cpyext/test/test_iterator.py
--- a/pypy/module/cpyext/test/test_iterator.py
+++ b/pypy/module/cpyext/test/test_iterator.py
@@ -33,6 +33,11 @@
                 return obj;
             '''
             ),
+           ("get_dictproxy", "METH_O",
+            '''
+                return PyDictProxy_New(args);
+            '''
+            ),
            ("check", "METH_O",
             '''
                 return PyInt_FromLong(
@@ -74,6 +79,10 @@
         assert operator.isMappingType(obj)
         #
         assert module.check(obj) == 2
+        # make sure dictionaries return false for PySequence_Check
+        assert module.check({'a': 1}) == 2
+        obj = module.get_dictproxy({'a': 10})
+        assert module.check(obj) == 2
 
     def test_iterable_nonmapping_object(self):
         module = self.import_extension('foo', [
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to