summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorŁukasz Langa <lukasz@langa.pl>2011-04-28 10:02:58 (GMT)
committerŁukasz Langa <lukasz@langa.pl>2011-04-28 10:02:58 (GMT)
commite812bf7bf6b7c1826b5e2c2488176a93cc6968bc (patch)
tree955499f7168c8e072f22f165ff6fa592f28dd7fc /Doc/library
parent2ea72709a34e57c9c131d7006ea80bdefbcf7bfe (diff)
parentba702daef9a8ac03d2d2fea4b1764d38b8debbd9 (diff)
downloadcpython-e812bf7bf6b7c1826b5e2c2488176a93cc6968bc.zip
cpython-e812bf7bf6b7c1826b5e2c2488176a93cc6968bc.tar.gz
cpython-e812bf7bf6b7c1826b5e2c2488176a93cc6968bc.tar.bz2
Merged styling updates for #11670 from 3.2.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/configparser.rst40
1 files changed, 17 insertions, 23 deletions
diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst
index 49e348f..1a88bbd 100644
--- a/Doc/library/configparser.rst
+++ b/Doc/library/configparser.rst
@@ -975,7 +975,7 @@ ConfigParser Objects
.. method:: read_file(f, source=None)
Read and parse configuration data from *f* which must be an iterable
- yielding Unicode strings (for example any file object).
+ yielding Unicode strings (for example files opened in text mode).
Optional argument *source* specifies the name of the file being read. If
not given and *f* has a :attr:`name` attribute, that is used for
@@ -984,28 +984,6 @@ ConfigParser Objects
.. versionadded:: 3.2
Replaces :meth:`readfp`.
- .. note::
-
- Prior to Python 3.2, :meth:`readfp` consumed lines from the file-like
- argument by calling its :meth:`~file.readline` method. 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()
- while line != '':
- yield line
- line = f.readline()
-
- Before::
-
- parser.readfp(f)
-
- After::
-
- parser.read_file(readline_generator(f))
-
.. method:: read_string(string, source='<string>')
Parse configuration data from a string.
@@ -1142,6 +1120,22 @@ ConfigParser Objects
.. deprecated:: 3.2
Use :meth:`read_file` instead.
+ .. versionchanged:: 3.2
+ :meth:`readfp` now iterates on *f* instead of calling ``f.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()
+ while line:
+ yield line
+ line = f.readline()
+
+ Instead of ``parser.readfp(f)`` use
+ ``parser.read_file(readline_generator(f))``.
+
.. data:: MAX_INTERPOLATION_DEPTH