open(False) in python3

geremy condra debatem1 at gmail.com
Tue May 11 17:40:36 EDT 2010


I'm unsure if this qualifies as a bug (it is also clearly user error) but I just
ran into a situation where open() was inadvertantly called on a False,
and I was somewhat surprised to see that this didn't bail horribly, but
rather hung forever. Here's some example sessions for python3.x and
python2.x:

<redacted>@<redacted>:~$ python3
Python 3.1.2 (r312:79147, Apr 15 2010, 12:35:07)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open(False)
>>> f.read()
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyboardInterrupt
>>>
<redacted>@<redacted>:~$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open(False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: coercing to Unicode: need string or buffer, bool found
>>>

Should I chalk this up to stupid coder syndrome or file a bug report?

Geremy Condra



More information about the Python-list mailing list