FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-37417: Fix error handling in bytearray.extend. by brandtbucher · Pull Request #14407 · python/cpython · GitHub

Repository navigation

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

Merged
serhiy-storchaka merged 3 commits into
python:masterfrom
brandtbucher:bytearray-extend
Jun 26, 2019
Merged

serhiy-storchaka merged 3 commits into
python:masterfrom
brandtbucher:bytearray-extend

Conversation

brandtbucher commented Jun 26, 2019 •
edited by bedevere-bot
Loading

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 added needs backport to 3.7 type-bug An unexpected behavior, bug, or error labels Jun 26, 2019
serhiy-storchaka merged commit 2a7d596 into python:master Jun 26, 2019

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.
🐍🍒⛏🤖

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>

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Member Author

Thanks @serhiy-storchaka!

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

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>

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>

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>

Copy link
Copy Markdown
Member

Thank you for your contribution, @brandtbucher!

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL