Issue1146
Created on 2008-10-09.07:01:24 by bupjae, last changed 2009-03-22.03:01:19 by zyasoft.
File name |
Uploaded |
Description |
Edit |
Remove |
fix1146.diff
|
rnk,
2008-10-10.22:32:39
|
Patch to fix issue. |
|
|
msg3647 (view) |
Author: Bupjae Lee (bupjae) |
Date: 2008-10-09.07:01:23 |
|
C:\jython2.5a3>jython
Jython 2.5a3 (trunk:5315:5317, Sep 10 2008, 20:54:23)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_07
Type "help", "copyright", "credits" or "license" for more information.
>>> import java
>>>
>>> x=java.util.Hashtable()
>>> x.put('test', 1)
>>> x
{test=1}
>>> dict(x)
{'test': 1}
>>>
>>> x=java.util.HashMap()
>>> x.put('test', 1)
>>> x
{test=1}
>>> dict(x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: dictionary update sequence element #0 has length 4; 2 is
required
>>>
I think behavior of dict() with java.util.HashMap is wrong.
|
msg3651 (view) |
Author: Reid Kleckner (rnk) |
Date: 2008-10-10.22:32:39 |
|
The problem was that PyDictionary was checking if the argument it was
passed had a 'keys' method and then calling it and iterating them.
Hashtable has a keys method, but HashMap and the Map interface have a
'keySet' method. If a keys method doesn't exist, PyDictionary iterates
the argument for key-value pairs. However, iterating HashMap produces
the keys, not the key-value pairs. Since strings in python are iterable
and support __len__, PyDictionary was complaining that it wasn't the
right length, ie a pair.
I've attached a patch to check if the object supports the keySet method,
and use that instead of the keys method. I also added a bugtest.
|
msg4200 (view) |
Author: Jim Baker (zyasoft) |
Date: 2009-03-08.07:32:13 |
|
To be fixed by the RC
|
msg4328 (view) |
Author: Jim Baker (zyasoft) |
Date: 2009-03-22.03:01:19 |
|
Fixed by r6106
|
|
Date |
User |
Action |
Args |
2009-03-22 03:01:19 | zyasoft | set | status: open -> closed keywords:
+ patch resolution: fixed messages:
+ msg4328 title: Different behavior between java.util.Hashtable and java.util.HashMap -> dict (PyDictionary) could not be constructed from a Map in user-level code |
2009-03-12 06:44:13 | zyasoft | set | priority: high |
2009-03-08 07:32:13 | zyasoft | set | messages:
+ msg4200 |
2008-10-14 17:38:32 | zyasoft | set | assignee: zyasoft nosy:
+ zyasoft |
2008-10-10 22:32:40 | rnk | set | files:
+ fix1146.diff nosy:
+ rnk messages:
+ msg3651 |
2008-10-09 07:01:24 | bupjae | create | |
|