[Jython-checkins] jython: Rename module _io to _jyio, _fileio module to _io.

jeff.allen jython-checkins at python.org
Mon Oct 1 10:12:50 CEST 2012


http://hg.python.org/jython/rev/85d67280589c
changeset:   6869:85d67280589c
user:        Jeff Allen <ja...py at farowl.co.uk>
date:        Wed Sep 19 23:09:23 2012 +0100
summary:
  Rename module _io to _jyio, _fileio module to _io.
This is preparatory to further development of the io and _io modules to make them ore like CPython and pass the test_io regression test. Changes are all directly connected with renaming. Errors are up, probably since our _io module does not implement everything it should. test_io fail, error, skip = (23, 72, 82)

files:
  CoreExposed.includes                                |     2 +-
  Lib/_io.py                                          |    19 +-
  lib-python/2.7/io.py                                |    32 +-
  Lib/test/test_io.py                                 |     6 +-
  src/org/python/modules/Setup.java                   |     2 +-
  src/org/python/modules/_fileio/PyFileIO.java        |    74 +-
  src/org/python/modules/_fileio/PyFileIODerived.java |  2250 +++++-----
  src/org/python/modules/_fileio/_fileio.java         |     8 +-
  src/templates/mappings                              |     2 +-
  9 files changed, 1206 insertions(+), 1189 deletions(-)


diff --git a/CoreExposed.includes b/CoreExposed.includes
--- a/CoreExposed.includes
+++ b/CoreExposed.includes
@@ -59,7 +59,7 @@
 org/python/modules/_csv/PyDialect.class
 org/python/modules/_csv/PyReader.class
 org/python/modules/_csv/PyWriter.class
-org/python/modules/_fileio/PyFileIO.class
+org/python/modules/_io/PyFileIO.class
 org/python/modules/_functools/PyPartial.class
 org/python/modules/_hashlib$Hash.class
 org/python/modules/itertools/chain.class
diff --git a/Lib/_io.py b/Lib/_jyio.py
rename from Lib/_io.py
rename to Lib/_jyio.py
--- a/Lib/_io.py
+++ b/Lib/_jyio.py
@@ -2,7 +2,7 @@
 XXX: This is actually io.py pulled from CPython 2.6 with the addition of some _
 onto the names of types. Eventually we should implement this stuff in Java.
 
-The _io module provides the Python interfaces to stream handling. The
+The _jyio module provides the Python interfaces to stream handling. The
 builtin open function is defined in this module.
 
 At the top of the I/O hierarchy is the abstract base class _IOBase. It
@@ -63,7 +63,7 @@
 import os
 import abc
 import codecs
-import _fileio
+import _io
 import threading
 
 # open() uses st_blksize whenever we can
@@ -135,7 +135,7 @@
 
     * Binary files are buffered in fixed-size chunks; the size of the buffer
       is chosen using a heuristic trying to determine the underlying device's
-      "block size" and falling back on `_io.DEFAULT_BUFFER_SIZE`.
+      "block size" and falling back on `_jyio.DEFAULT_BUFFER_SIZE`.
       On many systems, the buffer will typically be 4096 or 8192 bytes long.
 
     * "Interactive" text files (files for which isatty() returns True)
@@ -621,21 +621,22 @@
         self._unsupported("write")
 
 
-class FileIO(_fileio._FileIO, _RawIOBase):
+class FileIO(_io.FileIO, _RawIOBase):
 
     """Raw I/O implementation for OS files."""
 
-    # This multiply inherits from _FileIO and _RawIOBase to make
+    #XXX: have to read between these mangled CPython lines!
+    # This multiply inherits from FileIO and _RawIOBase to make
     # isinstance(_io.FileIO(), _io._RawIOBase) return True without requiring
-    # that _fileio._FileIO inherits from _io._RawIOBase (which would be hard
-    # to do since _fileio.c is written in C).
+    # that _io.FileIO inherits from _io._RawIOBase (which would be hard
+    # to do since fileio.c is written in C).
 
     def __init__(self, name, mode="r", closefd=True):
-        _fileio._FileIO.__init__(self, name, mode, closefd)
+        _io.FileIO.__init__(self, name, mode, closefd)
         self._name = name
 
     def close(self):
-        _fileio._FileIO.close(self)
+        _io.FileIO.close(self)
         _RawIOBase.close(self)
 
     @property
diff --git a/lib-python/2.7/io.py b/Lib/io.py
copy from lib-python/2.7/io.py
copy to Lib/io.py
--- a/lib-python/2.7/io.py
+++ b/Lib/io.py
@@ -1,3 +1,9 @@
+# XXX Temporary addition to Jython while we use _jyio.py in place of _io.
+# This module will stand in place of the lib-python io.py. The idea is
+# gradually to switch, in this module, between _jyio and _io as classes
+# are implemented in _io in Java. In the end, we delete this and _jyio.py,
+# and go back to using lib-python's io.py
+
 """The io module provides the Python interfaces to stream handling. The
 builtin open function is defined in this module.
 
@@ -57,15 +63,25 @@
            "UnsupportedOperation", "SEEK_SET", "SEEK_CUR", "SEEK_END"]
 
 
-import _io
+import _jyio
 import abc
 
-from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation,
-                 open, FileIO, BytesIO, StringIO, BufferedReader,
+# Gradually shorten this list
+from _jyio import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation,
+                 open,
+                 #FileIO,
+                 BytesIO, StringIO, BufferedReader,
                  BufferedWriter, BufferedRWPair, BufferedRandom,
                  IncrementalNewlineDecoder, TextIOWrapper)
 
-OpenWrapper = _io.open # for compatibility with _pyio
+# Gradually lengthen this list
+from _io import (FileIO,)
+#from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation,
+#                 open, FileIO, BytesIO, StringIO, BufferedReader,
+#                 BufferedWriter, BufferedRWPair, BufferedRandom,
+#                 IncrementalNewlineDecoder, TextIOWrapper)
+
+OpenWrapper = _jyio.open # for compatibility with _pyio
 
 # for seek()
 SEEK_SET = 0
@@ -75,16 +91,16 @@
 # Declaring ABCs in C is tricky so we do it here.
 # Method descriptions and default implementations are inherited from the C
 # version however.
-class IOBase(_io._IOBase):
+class IOBase(_jyio._IOBase):
     __metaclass__ = abc.ABCMeta
 
-class RawIOBase(_io._RawIOBase, IOBase):
+class RawIOBase(_jyio._RawIOBase, IOBase):
     pass
 
-class BufferedIOBase(_io._BufferedIOBase, IOBase):
+class BufferedIOBase(_jyio._BufferedIOBase, IOBase):
     pass
 
-class TextIOBase(_io._TextIOBase, IOBase):
+class TextIOBase(_jyio._TextIOBase, IOBase):
     pass
 
 RawIOBase.register(FileIO)
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -2949,9 +2949,9 @@
     py_io_ns.update((x.__name__, globs["Py" + x.__name__]) for x in mocks)
     # Avoid turning open into a bound method.
     py_io_ns["open"] = pyio.OpenWrapper
-    # XXX: While we use _io.py, the same trick is necessary for it too
-    import _io                              # XXX
-    c_io_ns["open"] = _io.OpenWrapper       # XXX
+    # XXX: While we use _jyio.py, the same trick is necessary for it too
+    import _jyio                              # XXX
+    c_io_ns["open"] = _jyio.OpenWrapper       # XXX
     for test in tests:
         if test.__name__.startswith("C"):
             for name, obj in c_io_ns.items():
diff --git a/src/org/python/modules/Setup.java b/src/org/python/modules/Setup.java
--- a/src/org/python/modules/Setup.java
+++ b/src/org/python/modules/Setup.java
@@ -61,6 +61,6 @@
         "_threading:org.python.modules._threading._threading",
         PosixModule.getOSName() + ":org.python.modules.posix.PosixModule",
         "jffi:org.python.modules.jffi.jffi",
-        "_fileio:org.python.modules._fileio._fileio"
+        "_io:org.python.modules._io._io"
     };
 }
diff --git a/src/org/python/modules/_fileio/PyFileIO.java b/src/org/python/modules/_io/PyFileIO.java
rename from src/org/python/modules/_fileio/PyFileIO.java
rename to src/org/python/modules/_io/PyFileIO.java
--- a/src/org/python/modules/_fileio/PyFileIO.java
+++ b/src/org/python/modules/_io/PyFileIO.java
@@ -1,5 +1,5 @@
 /* Copyright (c) Jython Developers */
-package org.python.modules._fileio;
+package org.python.modules._io;
 
 import java.nio.ByteBuffer;
 import java.util.concurrent.Callable;
@@ -23,7 +23,7 @@
 import org.python.expose.ExposedNew;
 import org.python.expose.ExposedType;
 
- at ExposedType(name = "_fileio._FileIO")
+ at ExposedType(name = "_io.FileIO")
 public class PyFileIO extends PyObject {
 
     public static final PyType TYPE = PyType.fromClass(PyFileIO.class);
@@ -52,7 +52,7 @@
 
     public PyFileIO(String name, String mode, boolean closefd) {
     	this();
-        _FileIO___init__(Py.newString(name), mode, closefd);
+        FileIO___init__(Py.newString(name), mode, closefd);
     }
 
     public PyFileIO(String name, String mode) {
@@ -61,7 +61,7 @@
 
     @ExposedNew
     @ExposedMethod(doc = BuiltinDocs.file___init___doc)
-    final void _FileIO___init__(PyObject[] args, String[] kwds) {
+    final void FileIO___init__(PyObject[] args, String[] kwds) {
         ArgParser ap = new ArgParser("file", args, kwds, new String[] {"name", "mode", "closefd"}, 1);
         PyObject name = ap.getPyObject(0);
         if (!(name instanceof PyString)) {
@@ -74,11 +74,11 @@
         if (!closefd)
         	throw Py.ValueError("Cannot use closefd=False with file name");
         
-        _FileIO___init__((PyString)name, mode, closefd);
+        FileIO___init__((PyString)name, mode, closefd);
         closer = new Closer(file, Py.getSystemState());
     }
 
-    private void _FileIO___init__(PyString name, String mode, boolean closefd) {
+    private void FileIO___init__(PyString name, String mode, boolean closefd) {
     	mode = parseMode(mode);
         this.name = name;
         this.mode = mode;
@@ -107,7 +107,7 @@
     }
 
     @ExposedMethod(doc = BuiltinDocs.file_close_doc)
-    final synchronized void _FileIO_close() {
+    final synchronized void FileIO_close() {
         if (closer != null) {
             closer.close();
             closer = null;
@@ -117,109 +117,109 @@
     }
 
     public void close() {
-        _FileIO_close();
+        FileIO_close();
     }
 
     public boolean readable() {
-        return _FileIO_readable();
+        return FileIO_readable();
     }
 
     @ExposedMethod(doc = "True if file was opened in a read mode.")
-    final boolean _FileIO_readable() {
+    final boolean FileIO_readable() {
         return file.readable();
     }
 
     @ExposedMethod(defaults = {"0"}, doc = BuiltinDocs.file_seek_doc)
-    final synchronized PyObject _FileIO_seek(long pos, int how) {
+    final synchronized PyObject FileIO_seek(long pos, int how) {
         checkClosed();
         return Py.java2py(file.seek(pos, how));
     }
 
     public boolean seekable() {
-        return _FileIO_seekable();
+        return FileIO_seekable();
     }
 
     @ExposedMethod(doc = "True if file supports random-access.")
-    final boolean _FileIO_seekable() {
+    final boolean FileIO_seekable() {
     	if (seekable == null)
     		seekable = file.seek(0, 0) >= 0;
     	return seekable;
     }
 
     @ExposedMethod(doc = BuiltinDocs.file_tell_doc)
-    final synchronized long _FileIO_tell() {
+    final synchronized long FileIO_tell() {
         checkClosed();
         return file.tell();
     }
 
     public long tell() {
-        return _FileIO_tell();
+        return FileIO_tell();
     }
 
     @ExposedMethod(defaults = {"null"}, doc = BuiltinDocs.file_truncate_doc)
-    final PyObject _FileIO_truncate(PyObject position) {
+    final PyObject FileIO_truncate(PyObject position) {
         if (position == null)
-            return Py.java2py(_FileIO_truncate());
-    	return Py.java2py(_FileIO_truncate(position.asLong()));
+            return Py.java2py(FileIO_truncate());
+    	return Py.java2py(FileIO_truncate(position.asLong()));
     }
 
-    final synchronized long _FileIO_truncate(long position) {
+    final synchronized long FileIO_truncate(long position) {
         return file.truncate(position);
     }
 
     public long truncate(long position) {
-        return _FileIO_truncate(position);
+        return FileIO_truncate(position);
     }
 
-    final synchronized long _FileIO_truncate() {
+    final synchronized long FileIO_truncate() {
         return file.truncate(file.tell());
     }
 
     public void truncate() {
-        _FileIO_truncate();
+        FileIO_truncate();
     }
 
     public boolean isatty() {
-        return _FileIO_isatty();
+        return FileIO_isatty();
     }
 
     @ExposedMethod(doc = BuiltinDocs.file_isatty_doc)
-    final boolean _FileIO_isatty() {
+    final boolean FileIO_isatty() {
         return file.isatty();
     }
 
     public boolean writable() {
-        return _FileIO_writable();
+        return FileIO_writable();
     }
 
     @ExposedMethod(doc = "True if file was opened in a write mode.")
-    final boolean _FileIO_writable() {
+    final boolean FileIO_writable() {
         return file.writable();
     }
 
     public PyObject fileno() {
-        return _FileIO_fileno();
+        return FileIO_fileno();
     }
 
     @ExposedMethod(doc = BuiltinDocs.file_fileno_doc)
-    final PyObject _FileIO_fileno() {
+    final PyObject FileIO_fileno() {
         return PyJavaType.wrapJavaObject(file.fileno());
     }
 
     @ExposedMethod(defaults = {"-1"}, doc = BuiltinDocs.file_read_doc)
-    final synchronized PyString _FileIO_read(int size) {
+    final synchronized PyString FileIO_read(int size) {
         checkClosed();
         ByteBuffer buf = file.read(size);
         return new PyString(StringUtil.fromBytes(buf));
     }
 
     public PyString read(int size) {
-        return _FileIO_read(size);
+        return FileIO_read(size);
     }
 
     @ExposedMethod(doc = BuiltinDocs.file_read_doc)
-    final synchronized PyString _FileIO_readall() {
-    	return _FileIO_read(-1);
+    final synchronized PyString FileIO_readall() {
+    	return FileIO_read(-1);
     }
 
     /**
@@ -243,7 +243,7 @@
     }
 
     @ExposedMethod(doc = BuiltinDocs.file_write_doc)
-    final PyObject _FileIO_write(PyObject obj) {
+    final PyObject FileIO_write(PyObject obj) {
     	String writable = asWritable(obj, null);
     	byte[] bytes = StringUtil.toBytes(writable);
         int written = write(ByteBuffer.wrap(bytes));
@@ -256,17 +256,17 @@
     }
 
     @ExposedMethod(names = {"__str__", "__repr__"}, doc = BuiltinDocs.file___str___doc)
-    final String _FileIO_toString() {
+    final String FileIO_toString() {
         if (name instanceof PyUnicode) {
             String escapedName = PyString.encode_UnicodeEscape(name.toString(), false);
-            return String.format("<_fileio.FileIO name='%s', mode='%s'>", escapedName, mode);
+            return String.format("<_io.FileIO name='%s', mode='%s'>", escapedName, mode);
         }
-        return String.format("<_fileio.FileIO name='%s', mode='%s'>", name, mode);
+        return String.format("<_io.FileIO name='%s', mode='%s'>", name, mode);
     }
 
     @Override
     public String toString() {
-        return _FileIO_toString();
+        return FileIO_toString();
     }
 
     private void checkClosed() {
diff --git a/src/org/python/modules/_fileio/PyFileIODerived.java b/src/org/python/modules/_io/PyFileIODerived.java
rename from src/org/python/modules/_fileio/PyFileIODerived.java
rename to src/org/python/modules/_io/PyFileIODerived.java
--- a/src/org/python/modules/_fileio/PyFileIODerived.java
+++ b/src/org/python/modules/_io/PyFileIODerived.java
@@ -1,1125 +1,1125 @@
-/* Generated file, do not modify.  See jython/src/templates/gderived.py. */
-package org.python.modules._fileio;
-
-import java.io.Serializable;
-import org.python.core.*;
-
-public class PyFileIODerived extends PyFileIO implements Slotted {
-
-    public PyObject getSlot(int index) {
-        return slots[index];
-    }
-
-    public void setSlot(int index,PyObject value) {
-        slots[index]=value;
-    }
-
-    private PyObject[]slots;
-
-    private PyObject dict;
-
-    public PyObject fastGetDict() {
-        return dict;
-    }
-
-    public PyObject getDict() {
-        return dict;
-    }
-
-    public void setDict(PyObject newDict) {
-        if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
-            dict=newDict;
-        } else {
-            throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
-        }
-    }
-
-    public void delDict() {
-        // deleting an object's instance dict makes it grow a new one
-        dict=new PyStringMap();
-    }
-
-    public PyFileIODerived(PyType subtype) {
-        super(subtype);
-        slots=new PyObject[subtype.getNumSlots()];
-        dict=subtype.instDict();
-    }
-
-    public PyString __str__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__str__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__();
-            if (res instanceof PyString)
-                return(PyString)res;
-            throw Py.TypeError("__str__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")");
-        }
-        return super.__str__();
-    }
-
-    public PyString __repr__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__repr__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__();
-            if (res instanceof PyString)
-                return(PyString)res;
-            throw Py.TypeError("__repr__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")");
-        }
-        return super.__repr__();
-    }
-
-    public PyString __hex__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__hex__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__();
-            if (res instanceof PyString)
-                return(PyString)res;
-            throw Py.TypeError("__hex__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")");
-        }
-        return super.__hex__();
-    }
-
-    public PyString __oct__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__oct__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__();
-            if (res instanceof PyString)
-                return(PyString)res;
-            throw Py.TypeError("__oct__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")");
-        }
-        return super.__oct__();
-    }
-
-    public PyFloat __float__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__float__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__();
-            if (res instanceof PyFloat)
-                return(PyFloat)res;
-            throw Py.TypeError("__float__"+" returned non-"+"float"+" (type "+res.getType().fastGetName()+")");
-        }
-        return super.__float__();
-    }
-
-    public PyComplex __complex__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__complex__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__();
-            if (res instanceof PyComplex)
-                return(PyComplex)res;
-            throw Py.TypeError("__complex__"+" returned non-"+"complex"+" (type "+res.getType().fastGetName()+")");
-        }
-        return super.__complex__();
-    }
-
-    public PyObject __pos__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__pos__");
-        if (impl!=null)
-            return impl.__get__(this,self_type).__call__();
-        return super.__pos__();
-    }
-
-    public PyObject __neg__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__neg__");
-        if (impl!=null)
-            return impl.__get__(this,self_type).__call__();
-        return super.__neg__();
-    }
-
-    public PyObject __abs__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__abs__");
-        if (impl!=null)
-            return impl.__get__(this,self_type).__call__();
-        return super.__abs__();
-    }
-
-    public PyObject __invert__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__invert__");
-        if (impl!=null)
-            return impl.__get__(this,self_type).__call__();
-        return super.__invert__();
-    }
-
-    public PyObject __reduce__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__reduce__");
-        if (impl!=null)
-            return impl.__get__(this,self_type).__call__();
-        return super.__reduce__();
-    }
-
-    public PyObject __dir__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__dir__");
-        if (impl!=null)
-            return impl.__get__(this,self_type).__call__();
-        return super.__dir__();
-    }
-
-    public PyObject __add__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__add__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__add__(other);
-    }
-
-    public PyObject __radd__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__radd__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__radd__(other);
-    }
-
-    public PyObject __sub__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__sub__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__sub__(other);
-    }
-
-    public PyObject __rsub__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__rsub__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__rsub__(other);
-    }
-
-    public PyObject __mul__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__mul__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__mul__(other);
-    }
-
-    public PyObject __rmul__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__rmul__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__rmul__(other);
-    }
-
-    public PyObject __div__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__div__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__div__(other);
-    }
-
-    public PyObject __rdiv__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__rdiv__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__rdiv__(other);
-    }
-
-    public PyObject __floordiv__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__floordiv__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__floordiv__(other);
-    }
-
-    public PyObject __rfloordiv__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__rfloordiv__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__rfloordiv__(other);
-    }
-
-    public PyObject __truediv__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__truediv__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__truediv__(other);
-    }
-
-    public PyObject __rtruediv__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__rtruediv__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__rtruediv__(other);
-    }
-
-    public PyObject __mod__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__mod__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__mod__(other);
-    }
-
-    public PyObject __rmod__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__rmod__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__rmod__(other);
-    }
-
-    public PyObject __divmod__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__divmod__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__divmod__(other);
-    }
-
-    public PyObject __rdivmod__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__rdivmod__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__rdivmod__(other);
-    }
-
-    public PyObject __rpow__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__rpow__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__rpow__(other);
-    }
-
-    public PyObject __lshift__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__lshift__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__lshift__(other);
-    }
-
-    public PyObject __rlshift__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__rlshift__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__rlshift__(other);
-    }
-
-    public PyObject __rshift__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__rshift__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__rshift__(other);
-    }
-
-    public PyObject __rrshift__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__rrshift__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__rrshift__(other);
-    }
-
-    public PyObject __and__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__and__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__and__(other);
-    }
-
-    public PyObject __rand__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__rand__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__rand__(other);
-    }
-
-    public PyObject __or__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__or__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__or__(other);
-    }
-
-    public PyObject __ror__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__ror__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__ror__(other);
-    }
-
-    public PyObject __xor__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__xor__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__xor__(other);
-    }
-
-    public PyObject __rxor__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__rxor__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__rxor__(other);
-    }
-
-    public PyObject __lt__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__lt__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__lt__(other);
-    }
-
-    public PyObject __le__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__le__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__le__(other);
-    }
-
-    public PyObject __gt__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__gt__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__gt__(other);
-    }
-
-    public PyObject __ge__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__ge__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__ge__(other);
-    }
-
-    public PyObject __eq__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__eq__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__eq__(other);
-    }
-
-    public PyObject __ne__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__ne__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__ne__(other);
-    }
-
-    public PyObject __iadd__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__iadd__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__iadd__(other);
-    }
-
-    public PyObject __isub__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__isub__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__isub__(other);
-    }
-
-    public PyObject __imul__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__imul__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__imul__(other);
-    }
-
-    public PyObject __idiv__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__idiv__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__idiv__(other);
-    }
-
-    public PyObject __ifloordiv__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__ifloordiv__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__ifloordiv__(other);
-    }
-
-    public PyObject __itruediv__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__itruediv__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__itruediv__(other);
-    }
-
-    public PyObject __imod__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__imod__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__imod__(other);
-    }
-
-    public PyObject __ipow__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__ipow__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__ipow__(other);
-    }
-
-    public PyObject __ilshift__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__ilshift__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__ilshift__(other);
-    }
-
-    public PyObject __irshift__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__irshift__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__irshift__(other);
-    }
-
-    public PyObject __iand__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__iand__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__iand__(other);
-    }
-
-    public PyObject __ior__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__ior__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__ior__(other);
-    }
-
-    public PyObject __ixor__(PyObject other) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__ixor__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(other);
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__ixor__(other);
-    }
-
-    public PyObject __int__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__int__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__();
-            if (res instanceof PyInteger||res instanceof PyLong)
-                return res;
-            throw Py.TypeError("__int__"+" should return an integer");
-        }
-        return super.__int__();
-    }
-
-    public PyObject __long__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__long__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__();
-            if (res instanceof PyLong||res instanceof PyInteger)
-                return res;
-            throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")");
-        }
-        return super.__long__();
-    }
-
-    public int hashCode() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__hash__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__();
-            if (res instanceof PyInteger) {
-                return((PyInteger)res).getValue();
-            } else
-                if (res instanceof PyLong) {
-                    return((PyLong)res).getValue().intValue();
-                }
-            throw Py.TypeError("__hash__ should return a int");
-        }
-        if (self_type.lookup("__eq__")!=null||self_type.lookup("__cmp__")!=null) {
-            throw Py.TypeError(String.format("unhashable type: '%.200s'",getType().fastGetName()));
-        }
-        return super.hashCode();
-    }
-
-    public PyUnicode __unicode__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__unicode__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__();
-            if (res instanceof PyUnicode)
-                return(PyUnicode)res;
-            if (res instanceof PyString)
-                return new PyUnicode((PyString)res);
-            throw Py.TypeError("__unicode__"+" should return a "+"unicode");
-        }
-        return super.__unicode__();
-    }
-
-    public int __cmp__(PyObject other) {
-        PyType self_type=getType();
-        PyObject[]where_type=new PyObject[1];
-        PyObject impl=self_type.lookup_where("__cmp__",where_type);
-        // Full Compatibility with CPython __cmp__:
-        // If the derived type don't override __cmp__, the
-        // *internal* super().__cmp__ should be called, not the
-        // exposed one. The difference is that the exposed __cmp__
-        // throws a TypeError if the argument is an instance of the same type.
-        if (impl==null||where_type[0]==TYPE||Py.isSubClass(TYPE,where_type[0])) {
-            return super.__cmp__(other);
-        }
-        PyObject res=impl.__get__(this,self_type).__call__(other);
-        if (res==Py.NotImplemented) {
-            return-2;
-        }
-        int c=res.asInt();
-        return c<0?-1:c>0?1:0;
-    }
-
-    public boolean __nonzero__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__nonzero__");
-        if (impl==null) {
-            impl=self_type.lookup("__len__");
-            if (impl==null)
-                return super.__nonzero__();
-        }
-        PyObject o=impl.__get__(this,self_type).__call__();
-        Class c=o.getClass();
-        if (c!=PyInteger.class&&c!=PyBoolean.class) {
-            throw Py.TypeError(String.format("__nonzero__ should return bool or int, returned %s",self_type.getName()));
-        }
-        return o.__nonzero__();
-    }
-
-    public boolean __contains__(PyObject o) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__contains__");
-        if (impl==null)
-            return super.__contains__(o);
-        return impl.__get__(this,self_type).__call__(o).__nonzero__();
-    }
-
-    public int __len__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__len__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__();
-            if (res instanceof PyInteger)
-                return((PyInteger)res).getValue();
-            throw Py.TypeError("__len__ should return a int");
-        }
-        return super.__len__();
-    }
-
-    public PyObject __iter__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__iter__");
-        if (impl!=null)
-            return impl.__get__(this,self_type).__call__();
-        impl=self_type.lookup("__getitem__");
-        if (impl==null)
-            return super.__iter__();
-        return new PySequenceIter(this);
-    }
-
-    public PyObject __iternext__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("next");
-        if (impl!=null) {
-            try {
-                return impl.__get__(this,self_type).__call__();
-            } catch (PyException exc) {
-                if (exc.match(Py.StopIteration))
-                    return null;
-                throw exc;
-            }
-        }
-        return super.__iternext__(); // ???
-    }
-
-    public PyObject __finditem__(PyObject key) { // ???
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__getitem__");
-        if (impl!=null)
-            try {
-                return impl.__get__(this,self_type).__call__(key);
-            } catch (PyException exc) {
-                if (exc.match(Py.LookupError))
-                    return null;
-                throw exc;
-            }
-        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 (exc.match(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
-        // exceptions (such as subclasses of KeyError).
-        //
-        // We are forced to duplicate the code, instead of defining __finditem__
-        // in terms of __getitem__. That's because PyObject defines __getitem__
-        // in terms of __finditem__. Therefore, we would end with an infinite
-        // loop when self_type.lookup("__getitem__") returns null:
-        //
-        //  __getitem__ -> super.__getitem__ -> __finditem__ -> __getitem__
-        //
-        // By duplicating the (short) lookup and call code, we are safe, because
-        // the call chains will be:
-        //
-        // __finditem__ -> super.__finditem__
-        //
-        // __getitem__ -> super.__getitem__ -> __finditem__ -> super.__finditem__
-
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__getitem__");
-        if (impl!=null)
-            return impl.__get__(this,self_type).__call__(key);
-        return super.__getitem__(key);
-    }
-
-    public void __setitem__(PyObject key,PyObject value) { // ???
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__setitem__");
-        if (impl!=null) {
-            impl.__get__(this,self_type).__call__(key,value);
-            return;
-        }
-        super.__setitem__(key,value);
-    }
-
-    public PyObject __getslice__(PyObject start,PyObject stop,PyObject step) { // ???
-        if (step!=null) {
-            return __getitem__(new PySlice(start,stop,step));
-        }
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__getslice__");
-        if (impl!=null) {
-            PyObject[]indices=PySlice.indices2(this,start,stop);
-            return impl.__get__(this,self_type).__call__(indices[0],indices[1]);
-        }
-        return super.__getslice__(start,stop,step);
-    }
-
-    public void __setslice__(PyObject start,PyObject stop,PyObject step,PyObject value) {
-        if (step!=null) {
-            __setitem__(new PySlice(start,stop,step),value);
-            return;
-        }
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__setslice__");
-        if (impl!=null) {
-            PyObject[]indices=PySlice.indices2(this,start,stop);
-            impl.__get__(this,self_type).__call__(indices[0],indices[1],value);
-            return;
-        }
-        super.__setslice__(start,stop,step,value);
-    }
-
-    public void __delslice__(PyObject start,PyObject stop,PyObject step) {
-        if (step!=null) {
-            __delitem__(new PySlice(start,stop,step));
-            return;
-        }
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__delslice__");
-        if (impl!=null) {
-            PyObject[]indices=PySlice.indices2(this,start,stop);
-            impl.__get__(this,self_type).__call__(indices[0],indices[1]);
-            return;
-        }
-        super.__delslice__(start,stop,step);
-    }
-
-    public void __delitem__(PyObject key) { // ???
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__delitem__");
-        if (impl!=null) {
-            impl.__get__(this,self_type).__call__(key);
-            return;
-        }
-        super.__delitem__(key);
-    }
-
-    public PyObject __call__(PyObject args[],String keywords[]) {
-        ThreadState ts=Py.getThreadState();
-        if (ts.recursion_depth++>ts.systemState.getrecursionlimit())
-            throw Py.RuntimeError("maximum __call__ recursion depth exceeded");
-        try {
-            PyType self_type=getType();
-            PyObject impl=self_type.lookup("__call__");
-            if (impl!=null)
-                return impl.__get__(this,self_type).__call__(args,keywords);
-            return super.__call__(args,keywords);
-        } finally {
-            --ts.recursion_depth;
-        }
-    }
-
-    public PyObject __findattr_ex__(String name) {
-        return Deriveds.__findattr_ex__(this,name);
-    }
-
-    public void __setattr__(String name,PyObject value) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__setattr__");
-        if (impl!=null) {
-            impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
-            return;
-        }
-        super.__setattr__(name,value);
-    }
-
-    public void __delattr__(String name) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__delattr__");
-        if (impl!=null) {
-            impl.__get__(this,self_type).__call__(PyString.fromInterned(name));
-            return;
-        }
-        super.__delattr__(name);
-    }
-
-    public PyObject __get__(PyObject obj,PyObject type) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__get__");
-        if (impl!=null) {
-            if (obj==null)
-                obj=Py.None;
-            if (type==null)
-                type=Py.None;
-            return impl.__get__(this,self_type).__call__(obj,type);
-        }
-        return super.__get__(obj,type);
-    }
-
-    public void __set__(PyObject obj,PyObject value) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__set__");
-        if (impl!=null) {
-            impl.__get__(this,self_type).__call__(obj,value);
-            return;
-        }
-        super.__set__(obj,value);
-    }
-
-    public void __delete__(PyObject obj) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__delete__");
-        if (impl!=null) {
-            impl.__get__(this,self_type).__call__(obj);
-            return;
-        }
-        super.__delete__(obj);
-    }
-
-    public PyObject __pow__(PyObject other,PyObject modulo) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__pow__");
-        if (impl!=null) {
-            PyObject res;
-            if (modulo==null) {
-                res=impl.__get__(this,self_type).__call__(other);
-            } else {
-                res=impl.__get__(this,self_type).__call__(other,modulo);
-            }
-            if (res==Py.NotImplemented)
-                return null;
-            return res;
-        }
-        return super.__pow__(other,modulo);
-    }
-
-    public void dispatch__init__(PyObject[]args,String[]keywords) {
-        Deriveds.dispatch__init__(this,args,keywords);
-    }
-
-    public PyObject __index__() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__index__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__();
-            if (res instanceof PyInteger||res instanceof PyLong) {
-                return res;
-            }
-            throw Py.TypeError(String.format("__index__ returned non-(int,long) (type %s)",res.getType().fastGetName()));
-        }
-        return super.__index__();
-    }
-
-    public Object __tojava__(Class c) {
-        // If we are not being asked by the "default" conversion to java, then
-        // we can provide this as the result, as long as it is a instance of the
-        // specified class. Without this, derived.__tojava__(PyObject.class)
-        // would broke. (And that's not pure speculation: PyReflectedFunction's
-        // ReflectedArgs asks for things like that).
-        if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) {
-            return this;
-        }
-        // Otherwise, we call the derived __tojava__, if it exists:
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__tojava__");
-        if (impl!=null)
-            return impl.__get__(this,self_type).__call__(Py.java2py(c)).__tojava__(Object.class);
-        return super.__tojava__(c);
-    }
-
-    public Object __coerce_ex__(PyObject o) {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__coerce__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__(o);
-            if (res==Py.NotImplemented)
-                return Py.None;
-            if (!(res instanceof PyTuple))
-                throw Py.TypeError("__coerce__ didn't return a 2-tuple");
-            return((PyTuple)res).getArray();
-        }
-        return super.__coerce_ex__(o);
-    }
-
-    public String toString() {
-        PyType self_type=getType();
-        PyObject impl=self_type.lookup("__repr__");
-        if (impl!=null) {
-            PyObject res=impl.__get__(this,self_type).__call__();
-            if (!(res instanceof PyString))
-                throw Py.TypeError("__repr__ returned non-string (type "+res.getType().fastGetName()+")");
-            return((PyString)res).toString();
-        }
-        return super.toString();
-    }
-
-}
+/* Generated file, do not modify.  See jython/src/templates/gderived.py. */
+package org.python.modules._io;
+
+import java.io.Serializable;
+import org.python.core.*;
+
+public class PyFileIODerived extends PyFileIO implements Slotted {
+
+    public PyObject getSlot(int index) {
+        return slots[index];
+    }
+
+    public void setSlot(int index,PyObject value) {
+        slots[index]=value;
+    }
+
+    private PyObject[]slots;
+
+    private PyObject dict;
+
+    public PyObject fastGetDict() {
+        return dict;
+    }
+
+    public PyObject getDict() {
+        return dict;
+    }
+
+    public void setDict(PyObject newDict) {
+        if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
+            dict=newDict;
+        } else {
+            throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
+        }
+    }
+
+    public void delDict() {
+        // deleting an object's instance dict makes it grow a new one
+        dict=new PyStringMap();
+    }
+
+    public PyFileIODerived(PyType subtype) {
+        super(subtype);
+        slots=new PyObject[subtype.getNumSlots()];
+        dict=subtype.instDict();
+    }
+
+    public PyString __str__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__str__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__();
+            if (res instanceof PyString)
+                return(PyString)res;
+            throw Py.TypeError("__str__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")");
+        }
+        return super.__str__();
+    }
+
+    public PyString __repr__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__repr__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__();
+            if (res instanceof PyString)
+                return(PyString)res;
+            throw Py.TypeError("__repr__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")");
+        }
+        return super.__repr__();
+    }
+
+    public PyString __hex__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__hex__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__();
+            if (res instanceof PyString)
+                return(PyString)res;
+            throw Py.TypeError("__hex__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")");
+        }
+        return super.__hex__();
+    }
+
+    public PyString __oct__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__oct__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__();
+            if (res instanceof PyString)
+                return(PyString)res;
+            throw Py.TypeError("__oct__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")");
+        }
+        return super.__oct__();
+    }
+
+    public PyFloat __float__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__float__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__();
+            if (res instanceof PyFloat)
+                return(PyFloat)res;
+            throw Py.TypeError("__float__"+" returned non-"+"float"+" (type "+res.getType().fastGetName()+")");
+        }
+        return super.__float__();
+    }
+
+    public PyComplex __complex__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__complex__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__();
+            if (res instanceof PyComplex)
+                return(PyComplex)res;
+            throw Py.TypeError("__complex__"+" returned non-"+"complex"+" (type "+res.getType().fastGetName()+")");
+        }
+        return super.__complex__();
+    }
+
+    public PyObject __pos__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__pos__");
+        if (impl!=null)
+            return impl.__get__(this,self_type).__call__();
+        return super.__pos__();
+    }
+
+    public PyObject __neg__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__neg__");
+        if (impl!=null)
+            return impl.__get__(this,self_type).__call__();
+        return super.__neg__();
+    }
+
+    public PyObject __abs__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__abs__");
+        if (impl!=null)
+            return impl.__get__(this,self_type).__call__();
+        return super.__abs__();
+    }
+
+    public PyObject __invert__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__invert__");
+        if (impl!=null)
+            return impl.__get__(this,self_type).__call__();
+        return super.__invert__();
+    }
+
+    public PyObject __reduce__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__reduce__");
+        if (impl!=null)
+            return impl.__get__(this,self_type).__call__();
+        return super.__reduce__();
+    }
+
+    public PyObject __dir__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__dir__");
+        if (impl!=null)
+            return impl.__get__(this,self_type).__call__();
+        return super.__dir__();
+    }
+
+    public PyObject __add__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__add__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__add__(other);
+    }
+
+    public PyObject __radd__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__radd__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__radd__(other);
+    }
+
+    public PyObject __sub__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__sub__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__sub__(other);
+    }
+
+    public PyObject __rsub__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__rsub__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__rsub__(other);
+    }
+
+    public PyObject __mul__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__mul__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__mul__(other);
+    }
+
+    public PyObject __rmul__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__rmul__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__rmul__(other);
+    }
+
+    public PyObject __div__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__div__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__div__(other);
+    }
+
+    public PyObject __rdiv__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__rdiv__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__rdiv__(other);
+    }
+
+    public PyObject __floordiv__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__floordiv__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__floordiv__(other);
+    }
+
+    public PyObject __rfloordiv__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__rfloordiv__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__rfloordiv__(other);
+    }
+
+    public PyObject __truediv__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__truediv__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__truediv__(other);
+    }
+
+    public PyObject __rtruediv__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__rtruediv__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__rtruediv__(other);
+    }
+
+    public PyObject __mod__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__mod__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__mod__(other);
+    }
+
+    public PyObject __rmod__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__rmod__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__rmod__(other);
+    }
+
+    public PyObject __divmod__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__divmod__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__divmod__(other);
+    }
+
+    public PyObject __rdivmod__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__rdivmod__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__rdivmod__(other);
+    }
+
+    public PyObject __rpow__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__rpow__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__rpow__(other);
+    }
+
+    public PyObject __lshift__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__lshift__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__lshift__(other);
+    }
+
+    public PyObject __rlshift__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__rlshift__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__rlshift__(other);
+    }
+
+    public PyObject __rshift__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__rshift__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__rshift__(other);
+    }
+
+    public PyObject __rrshift__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__rrshift__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__rrshift__(other);
+    }
+
+    public PyObject __and__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__and__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__and__(other);
+    }
+
+    public PyObject __rand__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__rand__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__rand__(other);
+    }
+
+    public PyObject __or__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__or__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__or__(other);
+    }
+
+    public PyObject __ror__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__ror__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__ror__(other);
+    }
+
+    public PyObject __xor__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__xor__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__xor__(other);
+    }
+
+    public PyObject __rxor__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__rxor__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__rxor__(other);
+    }
+
+    public PyObject __lt__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__lt__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__lt__(other);
+    }
+
+    public PyObject __le__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__le__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__le__(other);
+    }
+
+    public PyObject __gt__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__gt__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__gt__(other);
+    }
+
+    public PyObject __ge__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__ge__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__ge__(other);
+    }
+
+    public PyObject __eq__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__eq__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__eq__(other);
+    }
+
+    public PyObject __ne__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__ne__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__ne__(other);
+    }
+
+    public PyObject __iadd__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__iadd__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__iadd__(other);
+    }
+
+    public PyObject __isub__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__isub__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__isub__(other);
+    }
+
+    public PyObject __imul__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__imul__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__imul__(other);
+    }
+
+    public PyObject __idiv__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__idiv__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__idiv__(other);
+    }
+
+    public PyObject __ifloordiv__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__ifloordiv__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__ifloordiv__(other);
+    }
+
+    public PyObject __itruediv__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__itruediv__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__itruediv__(other);
+    }
+
+    public PyObject __imod__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__imod__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__imod__(other);
+    }
+
+    public PyObject __ipow__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__ipow__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__ipow__(other);
+    }
+
+    public PyObject __ilshift__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__ilshift__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__ilshift__(other);
+    }
+
+    public PyObject __irshift__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__irshift__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__irshift__(other);
+    }
+
+    public PyObject __iand__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__iand__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__iand__(other);
+    }
+
+    public PyObject __ior__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__ior__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__ior__(other);
+    }
+
+    public PyObject __ixor__(PyObject other) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__ixor__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(other);
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__ixor__(other);
+    }
+
+    public PyObject __int__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__int__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__();
+            if (res instanceof PyInteger||res instanceof PyLong)
+                return res;
+            throw Py.TypeError("__int__"+" should return an integer");
+        }
+        return super.__int__();
+    }
+
+    public PyObject __long__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__long__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__();
+            if (res instanceof PyLong||res instanceof PyInteger)
+                return res;
+            throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")");
+        }
+        return super.__long__();
+    }
+
+    public int hashCode() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__hash__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__();
+            if (res instanceof PyInteger) {
+                return((PyInteger)res).getValue();
+            } else
+                if (res instanceof PyLong) {
+                    return((PyLong)res).getValue().intValue();
+                }
+            throw Py.TypeError("__hash__ should return a int");
+        }
+        if (self_type.lookup("__eq__")!=null||self_type.lookup("__cmp__")!=null) {
+            throw Py.TypeError(String.format("unhashable type: '%.200s'",getType().fastGetName()));
+        }
+        return super.hashCode();
+    }
+
+    public PyUnicode __unicode__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__unicode__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__();
+            if (res instanceof PyUnicode)
+                return(PyUnicode)res;
+            if (res instanceof PyString)
+                return new PyUnicode((PyString)res);
+            throw Py.TypeError("__unicode__"+" should return a "+"unicode");
+        }
+        return super.__unicode__();
+    }
+
+    public int __cmp__(PyObject other) {
+        PyType self_type=getType();
+        PyObject[]where_type=new PyObject[1];
+        PyObject impl=self_type.lookup_where("__cmp__",where_type);
+        // Full Compatibility with CPython __cmp__:
+        // If the derived type don't override __cmp__, the
+        // *internal* super().__cmp__ should be called, not the
+        // exposed one. The difference is that the exposed __cmp__
+        // throws a TypeError if the argument is an instance of the same type.
+        if (impl==null||where_type[0]==TYPE||Py.isSubClass(TYPE,where_type[0])) {
+            return super.__cmp__(other);
+        }
+        PyObject res=impl.__get__(this,self_type).__call__(other);
+        if (res==Py.NotImplemented) {
+            return-2;
+        }
+        int c=res.asInt();
+        return c<0?-1:c>0?1:0;
+    }
+
+    public boolean __nonzero__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__nonzero__");
+        if (impl==null) {
+            impl=self_type.lookup("__len__");
+            if (impl==null)
+                return super.__nonzero__();
+        }
+        PyObject o=impl.__get__(this,self_type).__call__();
+        Class c=o.getClass();
+        if (c!=PyInteger.class&&c!=PyBoolean.class) {
+            throw Py.TypeError(String.format("__nonzero__ should return bool or int, returned %s",self_type.getName()));
+        }
+        return o.__nonzero__();
+    }
+
+    public boolean __contains__(PyObject o) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__contains__");
+        if (impl==null)
+            return super.__contains__(o);
+        return impl.__get__(this,self_type).__call__(o).__nonzero__();
+    }
+
+    public int __len__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__len__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__();
+            if (res instanceof PyInteger)
+                return((PyInteger)res).getValue();
+            throw Py.TypeError("__len__ should return a int");
+        }
+        return super.__len__();
+    }
+
+    public PyObject __iter__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__iter__");
+        if (impl!=null)
+            return impl.__get__(this,self_type).__call__();
+        impl=self_type.lookup("__getitem__");
+        if (impl==null)
+            return super.__iter__();
+        return new PySequenceIter(this);
+    }
+
+    public PyObject __iternext__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("next");
+        if (impl!=null) {
+            try {
+                return impl.__get__(this,self_type).__call__();
+            } catch (PyException exc) {
+                if (exc.match(Py.StopIteration))
+                    return null;
+                throw exc;
+            }
+        }
+        return super.__iternext__(); // ???
+    }
+
+    public PyObject __finditem__(PyObject key) { // ???
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__getitem__");
+        if (impl!=null)
+            try {
+                return impl.__get__(this,self_type).__call__(key);
+            } catch (PyException exc) {
+                if (exc.match(Py.LookupError))
+                    return null;
+                throw exc;
+            }
+        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 (exc.match(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
+        // exceptions (such as subclasses of KeyError).
+        //
+        // We are forced to duplicate the code, instead of defining __finditem__
+        // in terms of __getitem__. That's because PyObject defines __getitem__
+        // in terms of __finditem__. Therefore, we would end with an infinite
+        // loop when self_type.lookup("__getitem__") returns null:
+        //
+        //  __getitem__ -> super.__getitem__ -> __finditem__ -> __getitem__
+        //
+        // By duplicating the (short) lookup and call code, we are safe, because
+        // the call chains will be:
+        //
+        // __finditem__ -> super.__finditem__
+        //
+        // __getitem__ -> super.__getitem__ -> __finditem__ -> super.__finditem__
+
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__getitem__");
+        if (impl!=null)
+            return impl.__get__(this,self_type).__call__(key);
+        return super.__getitem__(key);
+    }
+
+    public void __setitem__(PyObject key,PyObject value) { // ???
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__setitem__");
+        if (impl!=null) {
+            impl.__get__(this,self_type).__call__(key,value);
+            return;
+        }
+        super.__setitem__(key,value);
+    }
+
+    public PyObject __getslice__(PyObject start,PyObject stop,PyObject step) { // ???
+        if (step!=null) {
+            return __getitem__(new PySlice(start,stop,step));
+        }
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__getslice__");
+        if (impl!=null) {
+            PyObject[]indices=PySlice.indices2(this,start,stop);
+            return impl.__get__(this,self_type).__call__(indices[0],indices[1]);
+        }
+        return super.__getslice__(start,stop,step);
+    }
+
+    public void __setslice__(PyObject start,PyObject stop,PyObject step,PyObject value) {
+        if (step!=null) {
+            __setitem__(new PySlice(start,stop,step),value);
+            return;
+        }
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__setslice__");
+        if (impl!=null) {
+            PyObject[]indices=PySlice.indices2(this,start,stop);
+            impl.__get__(this,self_type).__call__(indices[0],indices[1],value);
+            return;
+        }
+        super.__setslice__(start,stop,step,value);
+    }
+
+    public void __delslice__(PyObject start,PyObject stop,PyObject step) {
+        if (step!=null) {
+            __delitem__(new PySlice(start,stop,step));
+            return;
+        }
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__delslice__");
+        if (impl!=null) {
+            PyObject[]indices=PySlice.indices2(this,start,stop);
+            impl.__get__(this,self_type).__call__(indices[0],indices[1]);
+            return;
+        }
+        super.__delslice__(start,stop,step);
+    }
+
+    public void __delitem__(PyObject key) { // ???
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__delitem__");
+        if (impl!=null) {
+            impl.__get__(this,self_type).__call__(key);
+            return;
+        }
+        super.__delitem__(key);
+    }
+
+    public PyObject __call__(PyObject args[],String keywords[]) {
+        ThreadState ts=Py.getThreadState();
+        if (ts.recursion_depth++>ts.systemState.getrecursionlimit())
+            throw Py.RuntimeError("maximum __call__ recursion depth exceeded");
+        try {
+            PyType self_type=getType();
+            PyObject impl=self_type.lookup("__call__");
+            if (impl!=null)
+                return impl.__get__(this,self_type).__call__(args,keywords);
+            return super.__call__(args,keywords);
+        } finally {
+            --ts.recursion_depth;
+        }
+    }
+
+    public PyObject __findattr_ex__(String name) {
+        return Deriveds.__findattr_ex__(this,name);
+    }
+
+    public void __setattr__(String name,PyObject value) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__setattr__");
+        if (impl!=null) {
+            impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+            return;
+        }
+        super.__setattr__(name,value);
+    }
+
+    public void __delattr__(String name) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__delattr__");
+        if (impl!=null) {
+            impl.__get__(this,self_type).__call__(PyString.fromInterned(name));
+            return;
+        }
+        super.__delattr__(name);
+    }
+
+    public PyObject __get__(PyObject obj,PyObject type) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__get__");
+        if (impl!=null) {
+            if (obj==null)
+                obj=Py.None;
+            if (type==null)
+                type=Py.None;
+            return impl.__get__(this,self_type).__call__(obj,type);
+        }
+        return super.__get__(obj,type);
+    }
+
+    public void __set__(PyObject obj,PyObject value) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__set__");
+        if (impl!=null) {
+            impl.__get__(this,self_type).__call__(obj,value);
+            return;
+        }
+        super.__set__(obj,value);
+    }
+
+    public void __delete__(PyObject obj) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__delete__");
+        if (impl!=null) {
+            impl.__get__(this,self_type).__call__(obj);
+            return;
+        }
+        super.__delete__(obj);
+    }
+
+    public PyObject __pow__(PyObject other,PyObject modulo) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__pow__");
+        if (impl!=null) {
+            PyObject res;
+            if (modulo==null) {
+                res=impl.__get__(this,self_type).__call__(other);
+            } else {
+                res=impl.__get__(this,self_type).__call__(other,modulo);
+            }
+            if (res==Py.NotImplemented)
+                return null;
+            return res;
+        }
+        return super.__pow__(other,modulo);
+    }
+
+    public void dispatch__init__(PyObject[]args,String[]keywords) {
+        Deriveds.dispatch__init__(this,args,keywords);
+    }
+
+    public PyObject __index__() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__index__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__();
+            if (res instanceof PyInteger||res instanceof PyLong) {
+                return res;
+            }
+            throw Py.TypeError(String.format("__index__ returned non-(int,long) (type %s)",res.getType().fastGetName()));
+        }
+        return super.__index__();
+    }
+
+    public Object __tojava__(Class c) {
+        // If we are not being asked by the "default" conversion to java, then
+        // we can provide this as the result, as long as it is a instance of the
+        // specified class. Without this, derived.__tojava__(PyObject.class)
+        // would broke. (And that's not pure speculation: PyReflectedFunction's
+        // ReflectedArgs asks for things like that).
+        if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) {
+            return this;
+        }
+        // Otherwise, we call the derived __tojava__, if it exists:
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__tojava__");
+        if (impl!=null)
+            return impl.__get__(this,self_type).__call__(Py.java2py(c)).__tojava__(Object.class);
+        return super.__tojava__(c);
+    }
+
+    public Object __coerce_ex__(PyObject o) {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__coerce__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__(o);
+            if (res==Py.NotImplemented)
+                return Py.None;
+            if (!(res instanceof PyTuple))
+                throw Py.TypeError("__coerce__ didn't return a 2-tuple");
+            return((PyTuple)res).getArray();
+        }
+        return super.__coerce_ex__(o);
+    }
+
+    public String toString() {
+        PyType self_type=getType();
+        PyObject impl=self_type.lookup("__repr__");
+        if (impl!=null) {
+            PyObject res=impl.__get__(this,self_type).__call__();
+            if (!(res instanceof PyString))
+                throw Py.TypeError("__repr__ returned non-string (type "+res.getType().fastGetName()+")");
+            return((PyString)res).toString();
+        }
+        return super.toString();
+    }
+
+}
diff --git a/src/org/python/modules/_fileio/_fileio.java b/src/org/python/modules/_io/_io.java
rename from src/org/python/modules/_fileio/_fileio.java
rename to src/org/python/modules/_io/_io.java
--- a/src/org/python/modules/_fileio/_fileio.java
+++ b/src/org/python/modules/_io/_io.java
@@ -1,5 +1,5 @@
 /* Copyright (c) Jython Developers */
-package org.python.modules._fileio;
+package org.python.modules._io;
 
 import org.python.core.ClassDictInit;
 import org.python.core.PyObject;
@@ -8,14 +8,14 @@
 /**
  * The Python _fileio module.
  */
-public class _fileio implements ClassDictInit {
+public class _io implements ClassDictInit {
 
     public static final PyString __doc__ = new PyString("Fast implementation of io.FileIO.");
 
     public static void classDictInit(PyObject dict) {
-        dict.__setitem__("__name__", new PyString("_fileio"));
+        dict.__setitem__("__name__", new PyString("_io"));
         dict.__setitem__("__doc__", __doc__);
-        dict.__setitem__("_FileIO", PyFileIO.TYPE);
+        dict.__setitem__("FileIO", PyFileIO.TYPE);
 
         // Hide from Python
         dict.__setitem__("classDictInit", null);
diff --git a/src/templates/mappings b/src/templates/mappings
--- a/src/templates/mappings
+++ b/src/templates/mappings
@@ -8,7 +8,7 @@
 
 BaseException.derived:org.python.core.PyBaseExceptionDerived
 ClasspathPyImporter.derived:org.python.core.ClasspathPyImporterDerived
-PyFileIO.derived:org.python.modules._fileio.PyFileIODerived
+PyFileIO.derived:org.python.modules._io.PyFileIODerived
 array.derived:org.python.core.PyArrayDerived
 bytearray.derived:org.python.core.PyByteArrayDerived
 classmethod.derived:org.python.core.PyClassMethodDerived

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list