Fixed #34642 -- Added File.open() support for *args and **kwargs.

This commit is contained in:
Yves Weissig 2023-08-18 17:52:57 +01:00 committed by Mariusz Felisiak
parent ecb6085f6f
commit 369b498219
5 changed files with 27 additions and 5 deletions

View file

@ -46,11 +46,12 @@ The ``File`` class
The read/write mode for the file.
.. method:: open(mode=None)
.. method:: open(mode=None, *args, **kwargs)
Open or reopen the file (which also does ``File.seek(0)``).
The ``mode`` argument allows the same values
as Python's built-in :func:`python:open()`.
as Python's built-in :func:`python:open()`. ``*args`` and ``**kwargs``
are passed after ``mode`` to Python's built-in :func:`python:open`.
When reopening a file, ``mode`` will override whatever mode the file
was originally opened with; ``None`` means to reopen with the original
@ -58,6 +59,10 @@ The ``File`` class
It can be used as a context manager, e.g. ``with file.open() as f:``.
.. versionchanged:: 5.0
Support for passing ``*args`` and ``**kwargs`` was added.
.. method:: __iter__()
Iterate over the file yielding one line at a time.