Issue600790
Created on 2002-08-27.13:39:14 by rt_landers, last changed 2008-12-14.18:30:53 by fwierzbicki.
File name |
Uploaded |
Description |
Edit |
Remove |
bug_600790.py
|
cgroves,
2006-09-07.04:48:45
|
Transcription of the code in the description such that the next intrepid explorer doesn't have to convert entity refs. |
|
|
msg709 (view) |
Author: Rich Landers (rt_landers) |
Date: 2002-08-27.13:39:14 |
|
When subclassing a java.util.List in Jython
and I want to override __setitem__ to accept either
a symbolic name or an integer index. However, when
I define the __setitem__ method in my Jython subtype, I
get a "TypeError: only integer keys accepted"
exception. It seems that since __setitem__ was defined
*automatically* for the List, my overriding method is
never being called...
--------
from java.lang import String
from java.util import ArrayList
class GoofyListMapThing (ArrayList):
def __init__(self):
self._elements = {}
def __setitem__(self, key, element):
print "GoofyListMapThing::__setitem__"
# Handle string key or int key here...
def __getitem__(self, key):
print "GoofyListMapThing::__getitem__"
# Handle string key or int key here...
glmt = GoofyListMapThing()
glmt["my-key"] = String("Element-1") # fails!
|
msg710 (view) |
Author: Deleted User leouserz (leouserz) |
Date: 2006-12-21.19:23:23 |
|
This problem is caused by PyInstance always checking if it has a CollectionProxy(non-collection subclasses appear not to be affected). If so it executes the CollectionProxies __setitem__(there are others, look for usage of getCollection() in PyInstance). A possible patch is to check the various dictionaries before checking for a collection proxy and executing the returned function if there is one.
__findattr__ appears not to work, so the individual dictionaries may have to queried.
leouser
|
msg3919 (view) |
Author: Frank Wierzbicki (fwierzbicki) |
Date: 2008-12-14.18:30:53 |
|
Added test to test_list_jy.py. This is fixed, probably was fixed by
Charlie Groves when the java-newstyle-type branch was merged.
|
|
Date |
User |
Action |
Args |
2008-12-14 18:30:53 | fwierzbicki | set | status: open -> closed resolution: fixed messages:
+ msg3919 nosy:
+ fwierzbicki |
2002-08-27 13:39:14 | rt_landers | create | |
|