[New-bugs-announce] [issue30061] Check if PyObject_Size() raised an error

Serhiy Storchaka report at bugs.python.org
Wed Apr 12 16:58:52 EDT 2017


New submission from Serhiy Storchaka:

PyObject_Size(), PySequence_Size() and PyMapping_Size() can raise an exception. But not always this is checked after using them. This can lead to a crash. For example:

>>> import io
>>> class R(io.IOBase):
...     def readline(self): return None
... 
>>> next(R())
Fatal Python error: a function returned a result with an error set
TypeError: object of type 'NoneType' has no len()                                                                                                                      

The above exception was the direct cause of the following exception:

SystemError: <built-in function next> returned a result with an error set

Current thread 0xb749c700 (most recent call first):
  File "<stdin>", line 1 in <module>

----------
components: Extension Modules, IO, Interpreter Core
messages: 291573
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Check if PyObject_Size() raised an error
type: crash
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7

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


More information about the New-bugs-announce mailing list