mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #12797: Added custom opener parameter to builtin open() and FileIO.open().
This commit is contained in:
parent
ab06e3f285
commit
59142db6d3
7 changed files with 89 additions and 22 deletions
|
@ -458,7 +458,7 @@ I/O Base Classes
|
|||
Raw File I/O
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. class:: FileIO(name, mode='r', closefd=True)
|
||||
.. class:: FileIO(name, mode='r', closefd=True, opener=None)
|
||||
|
||||
:class:`FileIO` represents an OS-level file containing bytes data.
|
||||
It implements the :class:`RawIOBase` interface (and therefore the
|
||||
|
@ -479,6 +479,15 @@ Raw File I/O
|
|||
The :meth:`read` (when called with a positive argument), :meth:`readinto`
|
||||
and :meth:`write` methods on this class will only make one system call.
|
||||
|
||||
A custom opener can be used by passing a callable as *opener*. The underlying
|
||||
file descriptor for the file object is then obtained by calling *opener* with
|
||||
(*name*, *flags*). *opener* must return an open file descriptor (passing
|
||||
:mod:`os.open` as *opener* results in functionality similar to passing
|
||||
``None``).
|
||||
|
||||
.. versionchanged:: 3.3
|
||||
The *opener* parameter was added.
|
||||
|
||||
In addition to the attributes and methods from :class:`IOBase` and
|
||||
:class:`RawIOBase`, :class:`FileIO` provides the following data
|
||||
attributes and methods:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue