[New-bugs-announce] [issue29297] python3 open() does not check argument type before attempting to read() or write()

Mo Ali report at bugs.python.org
Tue Jan 17 09:43:36 EST 2017


New submission from Mo Ali:

Python3 open(), read(), or write()doesn't check argument type before action causing a hang.  Would like to catch exceptions but not without an exception to return.  See below.

Python3.6:
Python 3.6.0 (default, Dec 24 2016, 08:01:42)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> test = False
>>> with open(str(test)) as f:
...     fail = f.read()
...


python2.7:
╰─λ python2                                                                                                                                                                                     0 < 09:35:31
Python 2.7.13 (default, Dec 18 2016, 07:03:39)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> test = False
>>> with open(test) as f:
...     fail = f.read()
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: coercing to Unicode: need string or buffer, bool found

----------
messages: 285644
nosy: Mo Ali
priority: normal
severity: normal
status: open
title: python3 open() does not check argument type before attempting to read() or write()
type: crash
versions: Python 3.5

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


More information about the New-bugs-announce mailing list