From: <nr...@us...> - 2008-12-01 18:33:05
|
Revision: 5670 http://jython.svn.sourceforge.net/jython/?rev=5670&view=rev Author: nriley Date: 2008-12-01 18:33:00 +0000 (Mon, 01 Dec 2008) Log Message: ----------- PyStringMap should not be hashable, just as PyDictionary isn't. Modified Paths: -------------- trunk/jython/Lib/test/test_stringmap.py trunk/jython/src/org/python/core/PyStringMap.java Modified: trunk/jython/Lib/test/test_stringmap.py =================================================================== --- trunk/jython/Lib/test/test_stringmap.py 2008-12-01 01:14:21 UTC (rev 5669) +++ trunk/jython/Lib/test/test_stringmap.py 2008-12-01 18:33:00 UTC (rev 5670) @@ -62,7 +62,10 @@ for i in r.keys(): self.assert_(d.has_key(i)) self.assert_(i in d) - + + # Test unhashability + self.assertRaises(TypeError, hash, d) + def test_stringmap_in_mapping(self): class A: def __init__(self): Modified: trunk/jython/src/org/python/core/PyStringMap.java =================================================================== --- trunk/jython/src/org/python/core/PyStringMap.java 2008-12-01 01:14:21 UTC (rev 5669) +++ trunk/jython/src/org/python/core/PyStringMap.java 2008-12-01 18:33:00 UTC (rev 5670) @@ -500,4 +500,8 @@ return pyKey; } } + + public int hashCode() { + throw Py.TypeError(String.format("unhashable type: '%.200s'", getType().fastGetName())); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |