]> granicus.if.org Git - python/commitdiff
Issue #3160: the "bdist_wininst" distutils command didn't work.
authorAntoine Pitrou <solipsis@pitrou.net>
Thu, 4 Sep 2008 21:32:09 +0000 (21:32 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Thu, 4 Sep 2008 21:32:09 +0000 (21:32 +0000)
Reviewed by Trent Nelson.

Lib/distutils/command/bdist_wininst.py
Misc/NEWS

index ae7d4fde2e878c347a847e3ad5744b1501b6ccad..e997e8f09446547432ebb4e929058fc49a6b9e67 100644 (file)
@@ -260,13 +260,18 @@ class bdist_wininst(Command):
             cfgdata = cfgdata.encode("mbcs")
 
         # Append the pre-install script
-        cfgdata = cfgdata + "\0"
+        cfgdata = cfgdata + b"\0"
         if self.pre_install_script:
-            script_data = open(self.pre_install_script, "r").read()
-            cfgdata = cfgdata + script_data + "\n\0"
+            # We need to normalize newlines, so we open in text mode and
+            # convert back to bytes. "latin1" simply avoids any possible
+            # failures.
+            with open(self.pre_install_script, "r",
+                encoding="latin1") as script:
+                script_data = script.read().encode("latin1")
+            cfgdata = cfgdata + script_data + b"\n\0"
         else:
             # empty pre-install script
-            cfgdata = cfgdata + "\0"
+            cfgdata = cfgdata + b"\0"
         file.write(cfgdata)
 
         # The 'magic number' 0x1234567B is used to make sure that the
index 9bd063bc8dc41a54c4c2ade3f7cc76e05c5763c7..0e51c80c8bbc6f367cc20c0b0d7617c2b9ee494b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -77,6 +77,8 @@ C API
 Library
 -------
 
+- Issue #3160: the "bdist_wininst" distutils command didn't work.
+
 - Issue #1658: tkinter changes dict size during iteration in both
     tkinter.BaseWidget and tkinter.scrolledtext.ScrolledText.