Commit 10fce39a authored by Ben Nemec's avatar Ben Nemec Committed by Stephen Finucane

Explicitly read setup.cfg as utf-8 on Python 3

Per the referenced bug, relying on the terminal encoding to read
setup.cfg is not safe.  Unfortunately, Python 2 doesn't accept an
encoding when reading config files so we need a fallback path for
that version.

Change-Id: If49344db2f9139c0557f6acd17671163e02468a5
Closes-Bug: 1745396
parent 1f2c7314
......@@ -119,6 +119,11 @@ such as the ``extract_mesages`` section provided by Babel__.
# A comment on a dedicated line
.. note::
On Python 3 ``setup.cfg`` is explicitly read as UTF-8. On Python 2 the
encoding is dependent on the terminal encoding.
......@@ -214,7 +214,11 @@ def cfg_to_args(path='setup.cfg', script_args=()):
if not os.path.exists(path):
raise errors.DistutilsFileError("file '%s' does not exist" %
try:, encoding='utf-8')
except TypeError:
# Python 2 doesn't accept the encoding kwarg
config = {}
for section in parser.sections():
config[section] = dict()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment