mirror of
https://github.com/python/cpython
synced 2024-09-04 15:56:13 +00:00
Issue #11670: readfp(fp) parameter name is different to read_file(f)
This commit is contained in:
parent
9a454021a4
commit
1f10671fc8
|
@ -1161,20 +1161,20 @@ ConfigParser Objects
|
|||
Use :meth:`read_file` instead.
|
||||
|
||||
.. versionchanged:: 3.2
|
||||
:meth:`readfp` now iterates on *f* instead of calling ``f.readline()``.
|
||||
:meth:`readfp` now iterates on *fp* instead of calling ``fp.readline()``.
|
||||
|
||||
For existing code calling :meth:`readfp` with arguments which don't
|
||||
support iteration, the following generator may be used as a wrapper
|
||||
around the file-like object::
|
||||
|
||||
def readline_generator(f):
|
||||
line = f.readline()
|
||||
def readline_generator(fp):
|
||||
line = fp.readline()
|
||||
while line:
|
||||
yield line
|
||||
line = f.readline()
|
||||
line = fp.readline()
|
||||
|
||||
Instead of ``parser.readfp(f)`` use
|
||||
``parser.read_file(readline_generator(f))``.
|
||||
Instead of ``parser.readfp(fp)`` use
|
||||
``parser.read_file(readline_generator(fp))``.
|
||||
|
||||
|
||||
.. data:: MAX_INTERPOLATION_DEPTH
|
||||
|
|
Loading…
Reference in a new issue