Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-37417: Fix error handling in bytearray.extend.#14407

Merged
serhiy-storchaka merged 3 commits into
python:masterpython/cpython:masterfrom
brandtbucher:bytearray-extendbrandtbucher/cpython:bytearray-extendCopy head branch name to clipboard
Jun 26, 2019
Merged

bpo-37417: Fix error handling in bytearray.extend.#14407
serhiy-storchaka merged 3 commits into
python:masterpython/cpython:masterfrom
brandtbucher:bytearray-extendbrandtbucher/cpython:bytearray-extendCopy head branch name to clipboard

Conversation

@brandtbucher

@brandtbucher brandtbucher commented Jun 26, 2019

Copy link
Copy Markdown
Member

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. This patch adds a fix and a regression test.

https://bugs.python.org/issue37417

@serhiy-storchaka serhiy-storchaka added needs backport to 3.7 type-bug An unexpected behavior, bug, or error labels Jun 26, 2019
@serhiy-storchaka serhiy-storchaka merged commit 2a7d596 into python:master Jun 26, 2019
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @brandtbucher for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

I'm having trouble backporting to 3.8. Reason: 'Error 110 while writing to socket. Connection timed out.'. Please retry by removing and re-adding the needs backport to 3.8 label.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 26, 2019
(cherry picked from commit 2a7d596)

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

GH-14408 is a backport of this pull request to the 3.7 branch.

@brandtbucher

Copy link
Copy Markdown
Member Author

Thanks @serhiy-storchaka!

Just a heads-up, it looks like the 3.8 backport timed out...

@brandtbucher brandtbucher deleted the bytearray-extend branch June 26, 2019 19:14
miss-islington added a commit that referenced this pull request Jun 26, 2019
(cherry picked from commit 2a7d596)

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @brandtbucher for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 26, 2019
(cherry picked from commit 2a7d596)

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

GH-14410 is a backport of this pull request to the 3.8 branch.

miss-islington added a commit that referenced this pull request Jun 26, 2019
(cherry picked from commit 2a7d596)

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
@serhiy-storchaka

Copy link
Copy Markdown
Member

Thank you for your contribution, @brandtbucher!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.