summaryrefslogtreecommitdiff
path: root/Lib/configparser.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-07-29 12:17:40 +0000
committerGeorg Brandl <georg@python.org>2010-07-29 12:17:40 +0000
commit8dcaa7396fd89ec84a29ae90c7958d0618ee6c62 (patch)
tree5b4826c5b8c2ba9aac9395f65523b287ab91a79d /Lib/configparser.py
parentf206d0e3931b64aa3c8219badb9e0fbb81f1eb38 (diff)
downloadcpython-git-8dcaa7396fd89ec84a29ae90c7958d0618ee6c62.tar.gz
#9411: allow selecting an encoding for configparser files. Also adds a new test config file to test special cases.
Diffstat (limited to 'Lib/configparser.py')
-rw-r--r--Lib/configparser.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/configparser.py b/Lib/configparser.py
index 8c0546af74..7ad24d885b 100644
--- a/Lib/configparser.py
+++ b/Lib/configparser.py
@@ -61,7 +61,7 @@ ConfigParser -- responsible for parsing a list of
options(section)
Return list of configuration options for the named section.
- read(filenames)
+ read(filenames, encoding=None)
Read and parse the list of named configuration files, given by
name. A single filename is also allowed. Non-existing files
are ignored. Return list of successfully read files.
@@ -369,7 +369,7 @@ class RawConfigParser:
del opts['__name__']
return list(opts.keys())
- def read(self, filenames):
+ def read(self, filenames, encoding=None):
"""Read and parse a filename or a list of filenames.
Files that cannot be opened are silently ignored; this is
@@ -386,7 +386,7 @@ class RawConfigParser:
read_ok = []
for filename in filenames:
try:
- fp = open(filename)
+ fp = open(filename, encoding=encoding)
except IOError:
continue
self._read(fp, filename)