summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-09-22 13:53:14 (GMT)
committerGeorg Brandl <georg@python.org>2009-09-22 13:53:14 (GMT)
commit73753d354b41cab4d6cd15ed2308b9d1a6dc1514 (patch)
tree2e25d9f4da949429d056be5d789186a069d2846a /Doc/library
parent8355e7c4a50998414d62c96fa3980737681a481e (diff)
downloadcpython-73753d354b41cab4d6cd15ed2308b9d1a6dc1514.zip
cpython-73753d354b41cab4d6cd15ed2308b9d1a6dc1514.tar.gz
cpython-73753d354b41cab4d6cd15ed2308b9d1a6dc1514.tar.bz2
#6969: make it explicit that configparser writes/reads text files, and fix the example.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/configparser.rst15
1 files changed, 9 insertions, 6 deletions
diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst
index a54bc19..a5d3a77 100644
--- a/Doc/library/configparser.rst
+++ b/Doc/library/configparser.rst
@@ -231,9 +231,11 @@ RawConfigParser Objects
.. method:: RawConfigParser.readfp(fp, filename=None)
Read and parse configuration data from the file or file-like object in *fp*
- (only the :meth:`readline` method is used). If *filename* is omitted and *fp*
- has a :attr:`name` attribute, that is used for *filename*; the default is
- ``<???>``.
+ (only the :meth:`readline` method is used). The file-like object must
+ operate in text mode, i.e. return strings from :meth:`readline`.
+
+ If *filename* is omitted and *fp* has a :attr:`name` attribute, that is used
+ for *filename*; the default is ``<???>``.
.. method:: RawConfigParser.get(section, option)
@@ -279,8 +281,9 @@ RawConfigParser Objects
.. method:: RawConfigParser.write(fileobject)
- Write a representation of the configuration to the specified file object. This
- representation can be parsed by a future :meth:`read` call.
+ Write a representation of the configuration to the specified file object,
+ which must be opened in text mode (accepting strings). This representation
+ can be parsed by a future :meth:`read` call.
.. method:: RawConfigParser.remove_option(section, option)
@@ -370,7 +373,7 @@ An example of writing to a configuration file::
config.set('Section1', 'foo', '%(bar)s is %(baz)s!')
# Writing our configuration file to 'example.cfg'
- with open('example.cfg', 'wb') as configfile:
+ with open('example.cfg', 'w') as configfile:
config.write(configfile)
An example of reading the configuration file again::