[pypy-svn] r64313 - in pypy/trunk/pypy/translator/jvm: src/pypy test
niko at codespeak.net
niko at codespeak.net
Fri Apr 17 23:48:46 CEST 2009
Author: niko
Date: Fri Apr 17 23:48:46 2009
New Revision: 64313
Modified:
pypy/trunk/pypy/translator/jvm/src/pypy/PyPy.java
pypy/trunk/pypy/translator/jvm/test/test_dict.py
Log:
change ll_remove() to invoke containsKey() explicitly
rather than comparing return value of remove() against
null, as we sometimes use null as a value
Modified: pypy/trunk/pypy/translator/jvm/src/pypy/PyPy.java
==============================================================================
--- pypy/trunk/pypy/translator/jvm/src/pypy/PyPy.java (original)
+++ pypy/trunk/pypy/translator/jvm/src/pypy/PyPy.java Fri Apr 17 23:48:46 2009
@@ -942,11 +942,19 @@
// make the code generator smarter to avoid the duplicate code.
public static boolean ll_remove(HashMap map, Object key) {
- return map.remove(key) != null;
+ if (map.containsKey(key)) {
+ map.remove(key); // careful: we sometimes use null as a value
+ return true;
+ }
+ return false;
}
public static boolean ll_remove(CustomDict map, Object key) {
- return map.remove(key) != null;
+ if (map.containsKey(key)) {
+ map.remove(key); // careful: we sometimes use null as a value
+ return true;
+ }
+ return false;
}
public static DictItemsIterator ll_get_items_iterator(HashMap map) {
Modified: pypy/trunk/pypy/translator/jvm/test/test_dict.py
==============================================================================
--- pypy/trunk/pypy/translator/jvm/test/test_dict.py (original)
+++ pypy/trunk/pypy/translator/jvm/test/test_dict.py Fri Apr 17 23:48:46 2009
@@ -9,6 +9,13 @@
def test_recursive(self):
py.test.skip("JVM doesn't support recursive dicts")
+ def test_None_set(self):
+ def fn(k):
+ m = {k:None}
+ del m[k]
+ return 22
+ assert self.interpret(fn, [5]) == 22
+
class TestJvmEmptyDict(JvmTest, oodict.BaseTestEmptyDict):
pass
More information about the Pypy-commit
mailing list