New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fdopen() not guaranteed to have Python semantics #43117
Comments
The specification for seek() says: seek( offset[, whence])
Note that if the file is opened for appending (mode
'a' or 'a+'), any seek() operations will be undone at
the next write. Consider operating on an fdopen()ed file. The Python http://pxr.openlook.org/pxr/source/Modules/posixmodule.c#3530 However, the POSIX standard http://www.opengroup.org/onlinepubs/009695399/functions/fdopen.html says: "Although not explicitly required by this volume of Thus, to ensure Python semantics, Python's fdopen() For example, on Solaris, this optional O_APPEND http://cvs.opensolaris.org/source/xref/on/usr/src/lib/libc/port/stdio/fdopen.c?r=1.22#97 This has recently caused serious problems with the |
Logged In: YES freebsd 4.11 shows the same behaviour. import fcntl
import os
def test_fdopen_append():
def is_append(fd):
return bool(fcntl.fcntl(fd, fcntl.F_GETFL) &
os.O_APPEND)
fd = os.open("foo.txt", os.O_RDWR | os.O_CREAT)
assert fd != -1
print "is_append:", is_append(fd)
f=os.fdopen(fd, 'a')
print "after fdopen is_append:", is_append(fd)
test_fdopen_append() |
Logged In: YES patch here: |
Logged In: YES Applied patch in rev. 43501, 43502. |
Logged In: YES Shouldn't the documentation now state this change in This behaviour seems a little odd to me in fact. Can't we set [1] not sure what the ALLOW_THREAD thing does? |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: