homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: open() should not accept bool argument
Type: behavior Stage: resolved
Components: IO Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: jcea, lars.gustaebel, r.david.murray
Priority: normal Keywords:

Created on 2012年09月16日 10:15 by lars.gustaebel, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Messages (2)
msg170550 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2012年09月16日 10:15
Today I accidentally did this:
open(True).read()
Passing True as a file argument to open() does not fail, because a bool value is treated like an integer file descriptor (stdout in this case). Even worse is that the read() call hangs in an endless loop on my linux box. On windows I get an EBADF at least.
Wouldn't it be better if open() checked explicitly for a bool argument and raises a TypeError?
msg170554 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012年09月16日 13:35
I don't think so. We don't try to protect people from all their mistakes, and a file descriptor of 1 is valid, and True == 1.
History
Date User Action Args
2022年04月11日 14:57:36adminsetgithub: 60154
2012年09月17日 20:19:55jceasetnosy: + jcea
2012年09月16日 13:35:23r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg170554

resolution: wont fix
stage: resolved
2012年09月16日 10:15:15lars.gustaebelcreate

AltStyle によって変換されたページ (->オリジナル) /