#9411: allow selecting an encoding for configparser files. Also adds a new test config file to test special cases.
diff --git a/Lib/configparser.py b/Lib/configparser.py
index 8c0546a..7ad24d8 100644
--- a/Lib/configparser.py
+++ b/Lib/configparser.py
@@ -61,7 +61,7 @@
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 @@
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 @@
read_ok = []
for filename in filenames:
try:
- fp = open(filename)
+ fp = open(filename, encoding=encoding)
except IOError:
continue
self._read(fp, filename)