From: <pj...@us...> - 2008-07-21 02:00:41
|
Revision: 4978 http://jython.svn.sourceforge.net/jython/?rev=4978&view=rev Author: pjenvey Date: 2008-07-21 01:59:47 +0000 (Mon, 21 Jul 2008) Log Message: ----------- fix __finditem__(int) not trying subclasses' __getitem__ if the parent overrode it (like PySequence does) Modified Paths: -------------- trunk/jython/src/org/python/core/PyArrayDerived.java trunk/jython/src/org/python/core/PyBooleanDerived.java trunk/jython/src/org/python/core/PyClassMethodDerived.java trunk/jython/src/org/python/core/PyComplexDerived.java trunk/jython/src/org/python/core/PyDictionaryDerived.java trunk/jython/src/org/python/core/PyEnumerateDerived.java trunk/jython/src/org/python/core/PyFileDerived.java trunk/jython/src/org/python/core/PyFloatDerived.java trunk/jython/src/org/python/core/PyFrozenSetDerived.java trunk/jython/src/org/python/core/PyIntegerDerived.java trunk/jython/src/org/python/core/PyListDerived.java trunk/jython/src/org/python/core/PyLongDerived.java trunk/jython/src/org/python/core/PyModuleDerived.java trunk/jython/src/org/python/core/PyObjectDerived.java trunk/jython/src/org/python/core/PyPropertyDerived.java trunk/jython/src/org/python/core/PySetDerived.java trunk/jython/src/org/python/core/PySliceDerived.java trunk/jython/src/org/python/core/PyStringDerived.java trunk/jython/src/org/python/core/PySuperDerived.java trunk/jython/src/org/python/core/PyTupleDerived.java trunk/jython/src/org/python/core/PyTypeDerived.java trunk/jython/src/org/python/core/PyUnicodeDerived.java trunk/jython/src/org/python/modules/_weakref/ReferenceTypeDerived.java trunk/jython/src/org/python/modules/collections/PyDefaultDictDerived.java trunk/jython/src/org/python/modules/collections/PyDequeDerived.java trunk/jython/src/org/python/modules/random/PyRandomDerived.java trunk/jython/src/org/python/modules/thread/PyLocalDerived.java trunk/jython/src/org/python/modules/zipimport/zipimporterDerived.java trunk/jython/src/templates/object.derived Added Paths: ----------- trunk/jython/Lib/test/test_iter_jy.py Added: trunk/jython/Lib/test/test_iter_jy.py =================================================================== --- trunk/jython/Lib/test/test_iter_jy.py (rev 0) +++ trunk/jython/Lib/test/test_iter_jy.py 2008-07-21 01:59:47 UTC (rev 4978) @@ -0,0 +1,32 @@ +"""Misc iterator tests. + +Made for Jython. +""" +import test_support +import unittest + +class IterTestCase(unittest.TestCase): + + def test_fastiter(self): + class MyList(list): + def __getitem__(self, index): + return str(index) + '!' + class MyTuple(tuple): + def __getitem__(self, index): + return str(index) + '!' + self.assertEqual(iter(MyList(['a', 'b'])).next(), 'a') + self.assertEqual(iter(MyTuple(['a', 'b'])).next(), 'a') + + def test_slowiter(self): + class MyStr(str): + def __getitem__(self, index): + return str(index) + '!' + self.assertEqual(iter(MyStr('ab')).next(), '0!') + + +def test_main(): + test_support.run_unittest(IterTestCase) + + +if __name__ == '__main__': + test_main() Modified: trunk/jython/src/org/python/core/PyArrayDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyArrayDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyArrayDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyBooleanDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyBooleanDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyBooleanDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyClassMethodDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyClassMethodDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyClassMethodDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyComplexDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyComplexDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyComplexDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyDictionaryDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyDictionaryDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyDictionaryDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyEnumerateDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyEnumerateDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyEnumerateDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyFileDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyFileDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyFileDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyFloatDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyFloatDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyFloatDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyFrozenSetDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyFrozenSetDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyFrozenSetDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyIntegerDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyIntegerDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyIntegerDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyListDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyListDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyListDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyLongDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyLongDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyLongDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyModuleDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyModuleDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyModuleDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -767,6 +767,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyObjectDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyObjectDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyObjectDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyPropertyDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyPropertyDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyPropertyDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PySetDerived.java =================================================================== --- trunk/jython/src/org/python/core/PySetDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PySetDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PySliceDerived.java =================================================================== --- trunk/jython/src/org/python/core/PySliceDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PySliceDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyStringDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyStringDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyStringDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PySuperDerived.java =================================================================== --- trunk/jython/src/org/python/core/PySuperDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PySuperDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyTupleDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyTupleDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyTupleDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyTypeDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyTypeDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyTypeDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -767,6 +767,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/core/PyUnicodeDerived.java =================================================================== --- trunk/jython/src/org/python/core/PyUnicodeDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/core/PyUnicodeDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -791,6 +791,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/modules/_weakref/ReferenceTypeDerived.java =================================================================== --- trunk/jython/src/org/python/modules/_weakref/ReferenceTypeDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/modules/_weakref/ReferenceTypeDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -793,6 +793,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/modules/collections/PyDefaultDictDerived.java =================================================================== --- trunk/jython/src/org/python/modules/collections/PyDefaultDictDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/modules/collections/PyDefaultDictDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -793,6 +793,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/modules/collections/PyDequeDerived.java =================================================================== --- trunk/jython/src/org/python/modules/collections/PyDequeDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/modules/collections/PyDequeDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -793,6 +793,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/modules/random/PyRandomDerived.java =================================================================== --- trunk/jython/src/org/python/modules/random/PyRandomDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/modules/random/PyRandomDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -793,6 +793,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/modules/thread/PyLocalDerived.java =================================================================== --- trunk/jython/src/org/python/modules/thread/PyLocalDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/modules/thread/PyLocalDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -769,6 +769,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/org/python/modules/zipimport/zipimporterDerived.java =================================================================== --- trunk/jython/src/org/python/modules/zipimport/zipimporterDerived.java 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/org/python/modules/zipimport/zipimporterDerived.java 2008-07-21 01:59:47 UTC (rev 4978) @@ -769,6 +769,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom Modified: trunk/jython/src/templates/object.derived =================================================================== --- trunk/jython/src/templates/object.derived 2008-07-21 01:43:14 UTC (rev 4977) +++ trunk/jython/src/templates/object.derived 2008-07-21 01:59:47 UTC (rev 4978) @@ -179,6 +179,20 @@ return super.__finditem__(key); } + public PyObject __finditem__(int key) { + PyType self_type = getType(); + PyObject impl = self_type.lookup("__getitem__"); + if (impl != null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc, Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + public PyObject __getitem__(PyObject key) { // Same as __finditem__, without swallowing LookupErrors. This allows // __getitem__ implementations written in Python to raise custom This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |