[pypy-dev] fdopen(fd, 'w') whe fd is opened 'r'

Brian Kearns bdkearns at gmail.com
Sat Feb 21 23:44:12 CET 2015


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 <matti.picus at 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 at python.org
> https://mail.python.org/mailman/listinfo/pypy-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20150221/33e2e6a0/attachment.html>


More information about the pypy-dev mailing list