Skip to content

Commit 69f5806

Browse files
committed
Use UTF-8 for writing python stubs
Since Python3 is "UTF-8 first", this change should not cause problems.
1 parent 8b20091 commit 69f5806

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

setuptools/command/bdist_egg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __bootstrap__():
5454
__bootstrap__()
5555
"""
5656
).lstrip()
57-
with open(pyfile, 'w') as f:
57+
with open(pyfile, 'w', encoding="utf-8") as f:
5858
f.write(_stub_template % resource)
5959

6060

setuptools/command/build_ext.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,7 @@ def _write_stub_file(self, stub_file: str, ext: Extension, compile=False):
342342
if compile and os.path.exists(stub_file):
343343
raise BaseError(stub_file + " already exists! Please delete.")
344344
if not self.dry_run:
345-
f = open(stub_file, 'w')
346-
f.write(
345+
content = (
347346
'\n'.join([
348347
"def __bootstrap__():",
349348
" global __bootstrap__, __file__, __loader__",
@@ -369,7 +368,8 @@ def _write_stub_file(self, stub_file: str, ext: Extension, compile=False):
369368
"", # terminal \n
370369
])
371370
)
372-
f.close()
371+
with open(stub_file, 'w', encoding="utf-8") as f:
372+
f.write(content)
373373
if compile:
374374
self._compile_and_remove_stub(stub_file)
375375

setuptools/package_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ def gen_setup(self, filename, fragment, tmpdir):
717717
shutil.copy2(filename, dst)
718718
filename = dst
719719

720-
with open(os.path.join(tmpdir, 'setup.py'), 'w') as file:
720+
with open(os.path.join(tmpdir, 'setup.py'), 'w', encoding="utf-8") as file:
721721
file.write(
722722
"from setuptools import setup\n"
723723
"setup(name=%r, version=%r, py_modules=[%r])\n"

0 commit comments

Comments
 (0)