New submission from Kevin Orr:

When one uses a file object returned by `FileType.__call__` as a context 
manager, `sys.stdin`'s or `sys.stdout`'s `__exit__` will be triggered upon exit 
of the context, in turn calling their `close` method.

Perhaps the issue is that `sys.stdin` and `sys.stdout` have poor `__exit__` 
methods, but my proposal (and it's not a particularly clean one) is to override 
the file object's `__exit__` if it happens to be either `sys.stdin` or 
`sys.stdout` to simply return True when called.

----------
components: Library (Lib)
messages: 231249
nosy: keviv
priority: normal
severity: normal
status: open
title: argparse.FileType.__call__ returns unwrapped sys.stdin and stdout
type: behavior
versions: Python 2.7, Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22884>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to