Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1d6a16b

Browse files
committed
Issue #3160: the "bdist_wininst" distutils command didn't work.
Reviewed by Trent Nelson.
1 parent 95aee62 commit 1d6a16b

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

Lib/distutils/command/bdist_wininst.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,18 @@ def create_exe(self, arcname, fullname, bitmap=None):
260260
cfgdata = cfgdata.encode("mbcs")
261261

262262
# Append the pre-install script
263-
cfgdata = cfgdata + "\0"
263+
cfgdata = cfgdata + b"\0"
264264
if self.pre_install_script:
265-
script_data = open(self.pre_install_script, "r").read()
266-
cfgdata = cfgdata + script_data + "\n\0"
265+
# We need to normalize newlines, so we open in text mode and
266+
# convert back to bytes. "latin1" simply avoids any possible
267+
# failures.
268+
with open(self.pre_install_script, "r",
269+
encoding="latin1") as script:
270+
script_data = script.read().encode("latin1")
271+
cfgdata = cfgdata + script_data + b"\n\0"
267272
else:
268273
# empty pre-install script
269-
cfgdata = cfgdata + "\0"
274+
cfgdata = cfgdata + b"\0"
270275
file.write(cfgdata)
271276

272277
# The 'magic number' 0x1234567B is used to make sure that the

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ C API
7777
Library
7878
-------
7979

80+
- Issue #3160: the "bdist_wininst" distutils command didn't work.
81+
8082
- Issue #1658: tkinter changes dict size during iteration in both
8183
tkinter.BaseWidget and tkinter.scrolledtext.ScrolledText.
8284

0 commit comments

Comments
 (0)