[issue29297] python3 open() does not check argument type before attempting to read() or write()
Serhiy Storchaka
report at bugs.python.org
Tue Jan 17 10:20:15 EST 2017
Serhiy Storchaka added the comment:
Builtin open() in Python 3 (and io.open() in Python 2.7) accept unicode strings, byte strings and integers as the first arguments (general path-like objects also are supported in Python 3.6, but it doesn't matter). bool is a subtype of int, and False is equal to integer 0. 0 is a file descriptor of sys.stdin.
>>> import sys
>>> sys.stdin.fileno()
0
Thus open(False) is equivalent to open(sys.stdin.fileno()). It creates a file object that wraps the file descriptor 0. This is legitimate operation.
----------
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29297>
_______________________________________
More information about the Python-bugs-list
mailing list