summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/create.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/create.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/create.py')
-rw-r--r--Lib/packaging/create.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/packaging/create.py b/Lib/packaging/create.py
index ca82773..5432ffc 100644
--- a/Lib/packaging/create.py
+++ b/Lib/packaging/create.py
@@ -32,6 +32,7 @@ import glob
import re
import shutil
import sysconfig
+import tokenize
from configparser import RawConfigParser
from textwrap import dedent
from hashlib import md5
@@ -116,7 +117,9 @@ def load_setup():
This function load the setup file in all cases (even if it have already
been loaded before, because we are monkey patching its setup function with
a particular one"""
- with open("setup.py") as f:
+ with open("setup.py", "rb") as f:
+ encoding, lines = tokenize.detect_encoding(f.readline)
+ with open("setup.py", encoding=encoding) as f:
imp.load_module("setup", f, "setup.py", (".py", "r", imp.PY_SOURCE))