Commits

clach04 committed 0aa2568 Draft

Binary file fix for Windows didn't work for Unix

Check if os.O_BINARY is available.

  • Participants
  • Parent commits 72e3765

Comments (0)

Files changed (1)

       for suffix in ["", ".1", ".2", ".3", ".4", ".5", ".6", ".7", ".8", ".9"]:
          destfilename = os.path.join (".", upfilename + suffix)
          try:
-            destfile = os.open (destfilename, os.O_BINARY |os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0644)
+            open_flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL
+            if hasattr(os, 'O_BINARY'):
+               open_flags |= os.O_BINARY
+            destfile = os.open (destfilename, open_flags, 0644)
             break
          except OSError, e:
             if e.errno == errno.EEXIST: