[issue14156] argparse.FileType for '-' doesn't work for a mode of 'rb'

paul j3 report at bugs.python.org
Thu Apr 3 02:11:01 CEST 2014


paul j3 added the comment:

There are a couple of complications to using 'fileno'.

We probably don't want to close 'sys.stdin' or 'sys.stdout' (not even if they are redirected to other files?).  That means using:

    open(sys.stdin.fileno(), ..., closefd=False)

'closefd', on the other hand, has to be True for string file specifications.

But in 'test_argparse.py', 'sys.stdout' is redirected to an 'io.StringIO'.  This has many of the same features as an open file, but 'fileno' is not implemented.  So the TypeFile probably needs to make an exception for this case.  I don't how this will play with a 'BytesIO' for 'wb' cases.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14156>
_______________________________________


More information about the Python-bugs-list mailing list