[New-bugs-announce] [issue37417] bytearray.extend does not handle errors during iteration.

Brandt Bucher report at bugs.python.org
Wed Jun 26 14:21:02 EDT 2019


New submission from Brandt Bucher <brandtbucher at gmail.com>:

bytearray.extend doesn't properly handle errors that arise during iteration of the argument:

Python 3.9.0a0 (heads/master:5150d32, Jun 26 2019, 10:55:32) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> array = bytearray()
>>> bad_iter = map(int, "X")
>>> array.extend(bad_iter)
ValueError: invalid literal for int() with base 10: 'X'

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

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: <method 'extend' of 'bytearray' objects> returned a result with an error set

As far as I can tell, this bug is present on all versions of Python 3. I've attached a patch with a fix and a regression test.

----------
components: Interpreter Core
messages: 346655
nosy: brandtbucher
priority: normal
severity: normal
status: open
title: bytearray.extend does not handle errors during iteration.
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37417>
_______________________________________


More information about the New-bugs-announce mailing list