_io._IOBase, on which the io module depends directly.Implementation Note
The code is based heavily on the Jython 2.6-ish
_fileio.PyFileIO, the purely Java-accessible org. (both
Philip Jenvey's work), and the Python implementation in Lib/_pyio. We do not simply
delegate to the implementation in org.python.core.io because of the need to override
parts of the implementation in Python subclasses. A call to close(), for example, is
required to call flush(), but if delegated to the pure Java implementation would not
call the version of flush() overridden in a Python sub-class of
_io._IOBase. Equally, the use made by PyRawIOBase.read(int) of
readinto(bytearray) would not pick up the version of readinto defined
in Python.
| Modifier and Type | Field and Description |
|---|---|
| protected boolean | __closed
True if the object is closed to further client operations. |
| protected PyStringMap | __dict__
Provide a dictionary in the object, so that methods and attributes may be overridden at instance level. |
| public static final String | |
| public static final String | |
| private Closer | closer
The ioDelegate's closer object; ensures the stream is closed at shutdown |
| pack-priv static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final PyType | |
| public static final String | |
| public static final String |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | __del_builtin__()
Implements org.
|
| public PyObject | Returns: this objectCalled at the start of a context-managed suite (supporting the |
| public boolean | |
| public PyObject | __iter__()
Overrides org. Return an iterator on which |
| public PyObject | __iternext__()
Overrides org. Return the next element of the sequence that this is an iterator for. |
| public void | _checkClosed(String
optional custom message msg)Raise an error if the underlying IO stream is closed. |
| public final void | |
| public void | _checkReadable(String
optional custom message msg)Raise an error if the underlying IO stream is not readable. |
| public final void | |
| public void | _checkSeekable(String
optional custom message msg)Raise an error if the pointer of underlying IO stream is not capable of being positioned. |
| public final void | _checkSeekable()
Raise an error if the pointer of underlying IO stream is not capable of being positioned. |
| public void | _checkWritable(String
optional custom message msg)Raise an error if the underlying IO stream is not writable. |
| public final void | |
| pack-priv final PyObject | |
| pack-priv final boolean | |
| pack-priv static PyObject | _IOBase___new__(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords)
|
| pack-priv final void | |
| pack-priv final void | |
| pack-priv final void | |
| pack-priv final void | |
| pack-priv final void | |
| pack-priv final void | |
| pack-priv final PyObject | |
| pack-priv final void | |
| pack-priv final boolean | |
| pack-priv final PyObject | |
| pack-priv final boolean | |
| pack-priv final PyObject | |
| pack-priv final PyObject | |
| pack-priv final long | |
| pack-priv final boolean | |
| pack-priv final long | |
| pack-priv final long | |
| pack-priv final boolean | |
| pack-priv final void | |
| private PyObject | |
| public void | |
| public final boolean | |
| public final void | |
| public PyStringMap | |
| public PyObject | |
| public void | |
| public boolean | Returns: true if a console: false if not or we can't tellIs the stream known to be an interactive console? |
| public PyObject | Returns: next line from the stream or fileMay be called repeatedly to produce (usually) lines from this stream or file. |
| public boolean | |
| protected static PyBuffer | Returns: a 1D contiguous PyBuffer of bytesto be wrapped and presented as a buffer obj)Construct a PyBuffer on a given object suitable for writing to the underlying stream. |
| public PyObject | Returns: the line (or fragment)maximum number of bytes (<0 means no limit) limit)Return one line of text (bytes terminates by |
| public PyObject | Returns: the line (or fragment)Return one line of text (bytes terminates by |
| public PyObject | |
| public boolean | refersDirectlyTo(PyObject ob)
Implements org. Optional operation. |
| public long | Returns: the new current positionrelative to the specified point pos, int 0=from start, 1=from here, 2=from end whence)Position the read or write pointer at a given byte offset |
| public final long | Returns: the new current positionrelative to the start pos)Position the read or write pointer at a given byte offset |
| public boolean | Returns: True if may be positionedIs the stream capable of positioning the read/write pointer? |
| private static PyException | tailoredIOError(String msg, String oper)
Convenience method providing the exception in the _checkWhatever() methods. |
| protected static PyException | Returns: TypeError to throwof thing expected (or could any text) type, PyObject argument provided from which actual type will be reported arg)Convenience method providing the exception when an argument is not the expected type. |
| public long | |
| public int | traverse(Visitproc visit, Object arg)
Implements org. Traverses all directly contained |
| public long | |
| public long | Returns: the new sizeTruncate file to |
| protected PyException | Returns: the exception for throwingname of operation op)Convenience method returning a PyException(_io.UnsupportedOperation), ripe for throwing, and naming the unsupported operation. |
| public boolean | |
| protected static PyBuffer | Returns: a 1D contiguous PyBuffer of bytesto be wrapped and presented as a buffer obj)Construct a PyBuffer on a given object suitable for reading into from the underlying stream. |
| public void |
| __closed | back to summary |
|---|---|
| protected boolean __closed True if the object is closed to further client operations. It is the state accessed by
| |
| __dict__ | back to summary |
|---|---|
| protected PyStringMap __dict__ Provide a dictionary in the object, so that methods and attributes may be overridden at instance level. | |
| close_doc | back to summary |
|---|---|
| public static final String close_doc | |
| closed_doc | back to summary |
|---|---|
| public static final String closed_doc | |
| closer | back to summary |
|---|---|
| private Closer<PyIOBase> closer The ioDelegate's closer object; ensures the stream is closed at shutdown | |
| doc | back to summary |
|---|---|
| pack-priv static final String doc | |
| fileno_doc | back to summary |
|---|---|
| public static final String fileno_doc | |
| flush_doc | back to summary |
|---|---|
| public static final String flush_doc | |
| isatty_doc | back to summary |
|---|---|
| public static final String isatty_doc | |
| readable_doc | back to summary |
|---|---|
| public static final String readable_doc | |
| readline_doc | back to summary |
|---|---|
| public static final String readline_doc | |
| readlines_doc | back to summary |
|---|---|
| public static final String readlines_doc | |
| seek_doc | back to summary |
|---|---|
| public static final String seek_doc | |
| seekable_doc | back to summary |
|---|---|
| public static final String seekable_doc | |
| tell_doc | back to summary |
|---|---|
| public static final String tell_doc | |
| truncate_doc | back to summary |
|---|---|
| public static final String truncate_doc | |
| TYPE | back to summary |
|---|---|
| public static final PyType TYPE | |
| writable_doc | back to summary |
|---|---|
| public static final String writable_doc | |
| writelines_doc | back to summary |
|---|---|
| public static final String writelines_doc | |
| PyIOBase | back to summary |
|---|---|
| protected PyIOBase() | |
| PyIOBase | back to summary |
|---|---|
| protected PyIOBase(PyType subtype) | |
| __del_builtin__ | back to summary |
|---|---|
| public void __del_builtin__() Implements org. Doc from org.
| |
| __enter__ | back to summary |
|---|---|
| public PyObject __enter__() Called at the start of a context-managed suite (supporting the
| |
| __exit__ | back to summary |
|---|---|
| public boolean __exit__(PyObject type, PyObject value, PyObject traceback) Called at the end of a context-managed suite (supporting the
| |
| __iter__ | back to summary |
|---|---|
| public PyObject __iter__() Overrides org. Return an iterator on which
| |
| __iternext__ | back to summary |
|---|---|
| public PyObject __iternext__() Overrides org. Doc from org. Return the next element of the sequence that this is an iterator for. Returns null when the end of the sequence is reached.
| |
| _checkClosed | back to summary |
|---|---|
| public void _checkClosed(String msg) throws PyException Raise an error if the underlying IO stream is closed. (Note opposite sense from
| |
| _checkClosed | back to summary |
|---|---|
| public final void _checkClosed() throws PyException | |
| _checkReadable | back to summary |
|---|---|
| public void _checkReadable(String msg) Raise an error if the underlying IO stream is not readable.
| |
| _checkReadable | back to summary |
|---|---|
| public final void _checkReadable() Raise an error if the underlying IO stream is not readable.
| |
| _checkSeekable | back to summary |
|---|---|
| public void _checkSeekable(String msg) Raise an error if the pointer of underlying IO stream is not capable of being positioned.
| |
| _checkSeekable | back to summary |
|---|---|
| public final void _checkSeekable() Raise an error if the pointer of underlying IO stream is not capable of being positioned.
| |
| _checkWritable | back to summary |
|---|---|
| public void _checkWritable(String msg) throws PyException Raise an error if the underlying IO stream is not writable.
| |
| _checkWritable | back to summary |
|---|---|
| public final void _checkWritable() throws PyException Raise an error if the underlying IO stream is not writable.
| |
| _IOBase___enter__ | back to summary |
|---|---|
pack-priv final PyObject _IOBase___enter__()
| |
| _IOBase___exit__ | back to summary |
|---|---|
pack-priv final boolean _IOBase___exit__(PyObject type, PyObject value, PyObject traceback)
| |
| _IOBase___new__ | back to summary |
|---|---|
pack-priv static PyObject _IOBase___new__(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords)
| |
| _IOBase__checkClosed | back to summary |
|---|---|
pack-priv final void _IOBase__checkClosed(String msg) throws PyException
| |
| _IOBase__checkReadable | back to summary |
|---|---|
pack-priv final void _IOBase__checkReadable(String msg)
| |
| _IOBase__checkSeekable | back to summary |
|---|---|
pack-priv final void _IOBase__checkSeekable(String msg)
| |
| _IOBase__checkWritable | back to summary |
|---|---|
pack-priv final void _IOBase__checkWritable(String msg) throws PyException
| |
| _IOBase__unsupported | back to summary |
|---|---|
pack-priv final void _IOBase__unsupported(String name)
| |
| _IOBase_close | back to summary |
|---|---|
pack-priv final void _IOBase_close()
| |
| _IOBase_fileno | back to summary |
|---|---|
pack-priv final PyObject _IOBase_fileno()
| |
| _IOBase_flush | back to summary |
|---|---|
pack-priv final void _IOBase_flush()
| |
| _IOBase_isatty | back to summary |
|---|---|
pack-priv final boolean _IOBase_isatty()
| |
| _IOBase_next | back to summary |
|---|---|
pack-priv final PyObject _IOBase_next() throws PyException
| |
| _IOBase_readable | back to summary |
|---|---|
pack-priv final boolean _IOBase_readable() throws PyException
| |
| _IOBase_readline | back to summary |
|---|---|
pack-priv final PyObject _IOBase_readline(PyObject limit)
| |
| _IOBase_readlines | back to summary |
|---|---|
pack-priv final PyObject _IOBase_readlines(PyObject hint)
| |
| _IOBase_seek | back to summary |
|---|---|
pack-priv final long _IOBase_seek(long pos, int whence)
| |
| _IOBase_seekable | back to summary |
|---|---|
pack-priv final boolean _IOBase_seekable() throws PyException
| |
| _IOBase_tell | back to summary |
|---|---|
pack-priv final long _IOBase_tell()
| |
| _IOBase_truncate | back to summary |
|---|---|
pack-priv final long _IOBase_truncate(PyObject size)
| |
| _IOBase_writable | back to summary |
|---|---|
pack-priv final boolean _IOBase_writable() throws PyException
| |
| _IOBase_writelines | back to summary |
|---|---|
pack-priv final void _IOBase_writelines(PyObject lines)
| |
| _readline | back to summary |
|---|---|
| private PyObject _readline(int limit) | |
| close | back to summary |
|---|---|
| public void close() Close the stream. If closed already, this is a no-op. | |
| closed | back to summary |
|---|---|
| public final boolean closed() Is the stream closed against further client operations?
| |
| closed_readonly | back to summary |
|---|---|
public final void closed_readonly(boolean value)
| |
| fastGetDict | back to summary |
|---|---|
| public PyStringMap fastGetDict() Overrides org. Doc from org. xxx implements where meaningful
| |
| fileno | back to summary |
|---|---|
| public PyObject fileno() Return a file descriptor for the stream. A CPython file descriptor is an int, but this is not
the natural choice in Jython, since Java has no such convention of using integers. File
descriptors should be passed around opaquely, so their actual type is irrelevant, as long as
(say)
| |
| flush | back to summary |
|---|---|
| public void flush() Flush write buffers, or no-op for read-only and non-blocking streams. Irrespective of the concrete type of the i/o object, locally-buffered write data is written downstream. Whether the downstream in object is also flushed depends upon the specific type of this object. | |
| isatty | back to summary |
|---|---|
| public boolean isatty() Is the stream known to be an interactive console? This relies on the ability of the underlying stream to know, which is not always possible.
| |
| next | back to summary |
|---|---|
| public PyObject next() throws PyException May be called repeatedly to produce (usually) lines from this stream or file.
| |
| readable | back to summary |
|---|---|
| public boolean readable() throws PyException Is the stream readable?
| |
| readablePyBuffer | back to summary |
|---|---|
| protected static PyBuffer readablePyBuffer(PyObject obj) throws PyException Construct a PyBuffer on a given object suitable for writing to the underlying stream. The buffer returned will be navigable as a 1D contiguous sequence of bytes.
| |
| readline | back to summary |
|---|---|
| public PyObject readline(int limit) Return one line of text (bytes terminates by
| |
| readline | back to summary |
|---|---|
| public PyObject readline() Return one line of text (bytes terminates by
| |
| readlines | back to summary |
|---|---|
| public PyObject readlines(PyObject hint) Read a stream as a sequence of lines. | |
| refersDirectlyTo | back to summary |
|---|---|
| public boolean refersDirectlyTo(PyObject ob) Implements org. Doc from org. Optional operation.
Should only be implemented if it is more efficient
than calling
| |
| seek | back to summary |
|---|---|
| public long seek(long pos, int whence) Position the read or write pointer at a given byte offset
the new current position | |
| seek | back to summary |
|---|---|
| public final long seek(long pos) Position the read or write pointer at a given byte offset
| |
| seekable | back to summary |
|---|---|
| public boolean seekable() throws PyException Is the stream capable of positioning the read/write pointer?
| |
| tailoredIOError | back to summary |
|---|---|
| private static PyException tailoredIOError(String msg, String oper) Convenience method providing the exception in the _checkWhatever() methods. | |
| tailoredTypeError | back to summary |
|---|---|
| protected static PyException tailoredTypeError(String type, PyObject arg) Convenience method providing the exception when an argument is not the expected type. The
format is "type argument expected, got
TypeError to throw | |
| tell | back to summary |
|---|---|
| public long tell() Get the current stream position.
| |
| traverse | back to summary |
|---|---|
| public int traverse(Visitproc visit, Object arg) Implements org. Doc from org. Traverses all directly contained
| |
| truncate | back to summary |
|---|---|
| public long truncate(long size) Truncate file to
| |
| truncate | back to summary |
|---|---|
| public long truncate() Truncate file to
| |
| unsupported | back to summary |
|---|---|
| protected PyException unsupported(String op) Convenience method returning a PyException(_io.UnsupportedOperation), ripe for throwing, and naming the unsupported operation. Like many similar methods, this does not actually throw (raise) the exception: it should be thrown from the place where the problem is.
| |
| writable | back to summary |
|---|---|
| public boolean writable() throws PyException Is the stream writable?
| |
| writablePyBuffer | back to summary |
|---|---|
| protected static PyBuffer writablePyBuffer(PyObject obj) throws PyException Construct a PyBuffer on a given object suitable for reading into from the underlying stream. The buffer returned will be navigable as a 1D contiguous writable sequence of bytes.
| |
| writelines | back to summary |
|---|---|
| public void writelines(PyObject lines) Write an iterable sequence of strings to the stream. | |