[pypy-svn] r65509 - in pypy/branch/io-lang/pypy/lang/io: . test

david at codespeak.net david at codespeak.net
Sat May 30 16:10:58 CEST 2009


Author: david
Date: Sat May 30 16:10:56 2009
New Revision: 65509

Modified:
   pypy/branch/io-lang/pypy/lang/io/map.py
   pypy/branch/io-lang/pypy/lang/io/test/test_map.py
Log:
Restricted keys in maps to strings

Modified: pypy/branch/io-lang/pypy/lang/io/map.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/map.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/map.py	Sat May 30 16:10:56 2009
@@ -1,10 +1,12 @@
 from pypy.lang.io.register import register_method
-
+from pypy.lang.io.model import W_ImmutableSequence
 @register_method('Map', 'atPut', unwrap_spec=[object, object, object])
 def map_at_put(space, w_target, w_key, w_value):
+    assert isinstance(w_key, W_ImmutableSequence)
     w_target.at_put(w_key, w_value)
     return w_target
     
 @register_method('Map', 'at', unwrap_spec=[object, object])
 def map_at(space, w_target, w_key):
+    assert isinstance(w_key, W_ImmutableSequence)
     return w_target.at(w_key)
\ No newline at end of file

Modified: pypy/branch/io-lang/pypy/lang/io/test/test_map.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/test/test_map.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/test/test_map.py	Sat May 30 16:10:56 2009
@@ -29,6 +29,6 @@
     assert res.value == 'bar'
     
 def test_key_hashing():
-    inp = 'Map clone atPut(1, "bar") atPut(nil, "ipsum") atPut("foo", 123) at(nil)'
+    inp = 'Map clone atPut("1", "bar") atPut("nil", "ipsum") atPut("foo", 123) at("nil")'
     res, space = interpret(inp)
     assert res.value == 'ipsum'
\ No newline at end of file



More information about the Pypy-commit mailing list