Author: Carl Friedrich Bolz-Tereick <[email protected]>
Branch: expose-jsonmap
Changeset: r97928:31fef096292c
Date: 2019-11-01 22:14 +0100
http://bitbucket.org/pypy/pypy/changeset/31fef096292c/

Log:    handle repeated keys

diff --git a/pypy/module/__pypy__/interp_dictstructure.py 
b/pypy/module/__pypy__/interp_dictstructure.py
--- a/pypy/module/__pypy__/interp_dictstructure.py
+++ b/pypy/module/__pypy__/interp_dictstructure.py
@@ -17,6 +17,8 @@
             raise oefmt(space.w_TypeError, "expected unicode, got %T", w_x)
         u = space.utf8_w(w_x)
         m = m.get_next(w_x, u, 0, len(u), terminator)
+        if m is None:
+            raise oefmt(space.w_ValueError, "repeated key %R", w_x)
         if not m.is_state_useful():
             m.mark_useful(terminator)  # XXX too aggressive?
     return m
diff --git a/pypy/module/__pypy__/test/test_dictstructure.py 
b/pypy/module/__pypy__/test/test_dictstructure.py
--- a/pypy/module/__pypy__/test/test_dictstructure.py
+++ b/pypy/module/__pypy__/test/test_dictstructure.py
@@ -24,3 +24,8 @@
         from __pypy__ import newdictstructure, strategy
         m = newdictstructure([u"a"])
         assert repr(m) == "<DictStructure [u'a']>"
+
+    def test_repeated_key(self):
+        from __pypy__ import newdictstructure
+        with raises(ValueError):
+            newdictstructure([u"a", u"a"])
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to