fdopen(fd, 'w') whe fd is opened 'r'
What version of CPython did you compare with? This behavior was
added/changed in 2.7.8. CPython has the exact same test and it doesn't seem
to be skipped on Windows. Comparing directly with C fdopen does not make
sense because os.fdopen isn't just a direct call to fdopen (includes
verification of mode, fd, etc).
http://bugs.python.org/issue21191
On Sat, Feb 21, 2015 at 1:58 PM, Matti Picus
Looking at this test test_fdopen_keeps_fd_open_on_errors which fails on win32
It also fails when run with python -A, on cpython. It even fails in C when running the code from the MSDN example of fdopen, https://msdn.microsoft.com/en-us/library/dye30d82.aspx if you replace the mode flag "r" with "w", windows will happily repopen a read-only file in write mode.
The MSDN documentation is quiet on the issue of mode conflict between fd and a call to fdopen, where posix explicitly will return an error http://linux.die.net/man/3/fdopen "The mode of the stream (one of the values "r", "r+", "w", "w+", "a", "a+") must be compatible with the mode of the file descriptor." I could find any google results for complaints about win32's reckless behaviour.
Two courses of action are possible: - fix the test to reflect current cpython and pypy behaviour on win32 - file a bug with cpython and fix our win32 implementation to pass the current test
Any thoughts? Matti
_______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev
I tested with win32 2.7.8 The issue addressed in 21191 was that posix.fdopen was not closing fd on error. On windows there is no posix module so test_posix.py is skipped entirely. While the skipped test was modified in issue 21191 to test mode compatibility, posixmodule.c does not actually compare the input fd mode (perhaps via a call to fstat(fd, stat)? ) to the requested mode, rahter it only verifies that the requested mode itself is a valid mode for a call to fdopen. On windows posix.fdopen is exposed through os.fdopen, which AFAICT is only minimally tested outside of test_posix.py. On 22/02/2015 12:44 AM, Brian Kearns wrote:
What version of CPython did you compare with? This behavior was added/changed in 2.7.8. CPython has the exact same test and it doesn't seem to be skipped on Windows. Comparing directly with C fdopen does not make sense because os.fdopen isn't just a direct call to fdopen (includes verification of mode, fd, etc).
http://bugs.python.org/issue21191
On Sat, Feb 21, 2015 at 1:58 PM, Matti Picus
mailto:matti.picus@gmail.com> wrote: Looking at this test test_fdopen_keeps_fd_open_on_errors which fails on win32 http://buildbot.pypy.org/summary/longrepr?testname=AppTestPosix.%28%29.test_fdopen_keeps_fd_open_on_errors&builder=own-win-x86-32&build=442&mod=module.posix.test.test_posix2
It also fails when run with python -A, on cpython. It even fails in C when running the code from the MSDN example of fdopen, https://msdn.microsoft.com/en-us/library/dye30d82.aspx if you replace the mode flag "r" with "w", windows will happily repopen a read-only file in write mode.
The MSDN documentation is quiet on the issue of mode conflict between fd and a call to fdopen, where posix explicitly will return an error http://linux.die.net/man/3/fdopen "The mode of the stream (one of the values "r", "r+", "w", "w+", "a", "a+") must be compatible with the mode of the file descriptor." I could find any google results for complaints about win32's reckless behaviour.
Two courses of action are possible: - fix the test to reflect current cpython and pypy behaviour on win32 - file a bug with cpython and fix our win32 implementation to pass the current test
Any thoughts? Matti
_______________________________________________ pypy-dev mailing list pypy-dev@python.org mailto:pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev
participants (2)
-
Brian Kearns
-
Matti Picus