Commit c6d52edd authored by Éric Araujo's avatar Éric Araujo

Fix usage of bytes in packaging's bdist_wininst.

This is copied from the namesake distutils command; there is no
automated test, so buildbots won’t call for my head this time, but it
should be okay as Python 3 users have tested the distutils command.
parent 030cfe26
"""Create an executable installer for Windows.""" """Create an executable installer for Windows."""
# FIXME synchronize bytes/str use with same file in distutils
import sys import sys
import os import os
...@@ -264,14 +262,17 @@ class bdist_wininst(Command): ...@@ -264,14 +262,17 @@ class bdist_wininst(Command):
cfgdata = cfgdata.encode("mbcs") cfgdata = cfgdata.encode("mbcs")
# Append the pre-install script # Append the pre-install script
cfgdata = cfgdata + "\0" cfgdata = cfgdata + b"\0"
if self.pre_install_script: if self.pre_install_script:
with open(self.pre_install_script) as fp: # We need to normalize newlines, so we open in text mode and
script_data = fp.read() # convert back to bytes. "latin-1" simply avoids any possible
cfgdata = cfgdata + script_data + "\n\0" # failures.
with open(self.pre_install_script, encoding="latin-1") as fp:
script_data = fp.read().encode("latin-1")
cfgdata = cfgdata + script_data + b"\n\0"
else: else:
# empty pre-install script # empty pre-install script
cfgdata = cfgdata + "\0" cfgdata = cfgdata + b"\0"
file.write(cfgdata) file.write(cfgdata)
# The 'magic number' 0x1234567B is used to make sure that the # The 'magic number' 0x1234567B is used to make sure that the
......
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