Issue 8399: Document os.open - Python tracker (original) (raw)

Issue8399

Created on 2010-04-14 13:26 by techtonik, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
8399.os-open-default-behavior.diff techtonik,2010-04-14 18:53
Messages (5)
msg103128 - (view) Author: anatoly techtonik (techtonik) Date: 2010-04-14 13:26
Need to document the that os.O_BINARY flag is obligatory for cross-platform behavior of os.open() on Windows. By default os.open() opens file as binary on Unix, but as text on Windows. See also for discussion of making os.O_BINARY default on py3k. I can reopen this issue.
msg103130 - (view) Author: anatoly techtonik (techtonik) Date: 2010-04-14 13:40
s/ can / can't /
msg103131 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-04-14 13:50
Since there is no distinction between text and binary mode on Unix, you shouldn't claim the behavior is not consistent - you get text mode. You need O_BINARY on Windows to get binary mode. O_BINARY is already documented; I've added a better link to it from the description of os.open() in r80069. Do not reopen #2028, it was not about os.open() anyway. For os.open(), as it is only a wrapper for the OS's own POSIX layer, the flags argument shouldn't be touched.
msg103139 - (view) Author: anatoly techtonik (techtonik) Date: 2010-04-14 18:53
On Unix all files are opened in binary mode. On Windows linefeeds are translated to CRLF corrupting files that are meant to be binary. This is the reason of HgGit failure - it uses Dulwich library that creates corrupted Git index file, because on Windows it is opened without os.O_BINARY flag. Developers do not know anything about it, because they develop on Unix. This could be prevented if we supply a note about how to preserve crossplatform behavior. https://bugs.edge.launchpad.net/dulwich/+bug/557585 I've attached a patch that adds required note. Please revise it. It should clearly apply over your changes in r80069. I reworded description towards Python users without C background, but I am still worried that they need a POSIX background to understand umask part.
msg103142 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-04-14 19:17
I've added a paragraph about O_BINARY in r80080.
History
Date User Action Args
2022-04-11 14:56:59 admin set github: 52646
2010-04-14 19:17:45 georg.brandl set status: open -> closedmessages: +
2010-04-14 18:53:45 techtonik set status: closed -> openfiles: + 8399.os-open-default-behavior.diffmessages: + keywords: + patch
2010-04-14 13:50:47 georg.brandl set status: open -> closedresolution: fixedmessages: +
2010-04-14 13:40:01 techtonik set messages: +
2010-04-14 13:26:01 techtonik create