summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/util.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-19 19:42:47 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-19 19:42:47 (GMT)
commit9cf6d131411f1e9bca2f094137a970b711b664c4 (patch)
tree5ecdeaeb3124d157a04afab8ac6f94764a116383 /Lib/packaging/util.py
parent975077a88912d723c7c3277f5abc8b7497f63e2a (diff)
downloadcpython-9cf6d131411f1e9bca2f094137a970b711b664c4.zip
cpython-9cf6d131411f1e9bca2f094137a970b711b664c4.tar.gz
cpython-9cf6d131411f1e9bca2f094137a970b711b664c4.tar.bz2
Issue #12112: fix the encoding of setup.py in the packaging module
* read: use tokenize.detect_encoding() * write: use 'utf-8'
Diffstat (limited to 'Lib/packaging/util.py')
-rw-r--r--Lib/packaging/util.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/packaging/util.py b/Lib/packaging/util.py
index 058f13e..71ce819 100644
--- a/Lib/packaging/util.py
+++ b/Lib/packaging/util.py
@@ -346,9 +346,9 @@ def byte_compile(py_files, optimize=0, force=False, prefix=None,
logger.info("writing byte-compilation script '%s'", script_name)
if not dry_run:
if script_fd is not None:
- script = os.fdopen(script_fd, "w")
+ script = os.fdopen(script_fd, "w", encoding='utf-8')
else:
- script = open(script_name, "w")
+ script = open(script_name, "w", encoding='utf-8')
with script:
script.write("""\
@@ -1087,7 +1087,7 @@ def generate_setup_py():
if os.path.exists("setup.py"):
raise PackagingFileError("a setup.py file alreadyexists")
- with open("setup.py", "w") as fp:
+ with open("setup.py", "w", encoding='utf-8') as fp:
fp.write(_SETUP_TMPL % {'func': getsource(cfg_to_args)})