This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Document os.open
Type: behavior Stage:
Components: Documentation, Library (Lib) Versions: Python 3.1, Python 3.2, Python 3.3, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, techtonik
Priority: normal Keywords: patch

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 issue2028 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:59adminsetgithub: 52646
2010-04-14 19:17:45georg.brandlsetstatus: open -> closed

messages: + msg103142
2010-04-14 18:53:45techtoniksetstatus: closed -> open
files: + 8399.os-open-default-behavior.diff
messages: + msg103139

keywords: + patch
2010-04-14 13:50:47georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg103131
2010-04-14 13:40:01techtoniksetmessages: + msg103130
2010-04-14 13:26:01techtonikcreate