Issues #11670: Merge configparser doc from 3.6

This commit is contained in:
Martin Panter 2017-01-29 23:37:50 +00:00
commit d5feb49711
1 changed files with 6 additions and 6 deletions

View File

@ -1161,20 +1161,20 @@ ConfigParser Objects
Use :meth:`read_file` instead. Use :meth:`read_file` instead.
.. versionchanged:: 3.2 .. 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 For existing code calling :meth:`readfp` with arguments which don't
support iteration, the following generator may be used as a wrapper support iteration, the following generator may be used as a wrapper
around the file-like object:: around the file-like object::
def readline_generator(f): def readline_generator(fp):
line = f.readline() line = fp.readline()
while line: while line:
yield line yield line
line = f.readline() line = fp.readline()
Instead of ``parser.readfp(f)`` use Instead of ``parser.readfp(fp)`` use
``parser.read_file(readline_generator(f))``. ``parser.read_file(readline_generator(fp))``.
.. data:: MAX_INTERPOLATION_DEPTH .. data:: MAX_INTERPOLATION_DEPTH