Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bytearray.extend does not handle errors during iteration. #81598

Closed
brandtbucher opened this issue Jun 26, 2019 · 4 comments
Closed

bytearray.extend does not handle errors during iteration. #81598

brandtbucher opened this issue Jun 26, 2019 · 4 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@brandtbucher
Copy link
Member

BPO 37417
Nosy @serhiy-storchaka, @miss-islington, @brandtbucher
PRs
  • bpo-37417: Fix error handling in bytearray.extend. #14407
  • [3.7] bpo-37417: Fix error handling in bytearray.extend. (GH-14407) #14408
  • [3.8] bpo-37417: Fix error handling in bytearray.extend. (GH-14407) #14410
  • bpo-37420: os.sched_setaffinity does not handle errors during iteration. #14414
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-06-26.20:17:31.538>
    created_at = <Date 2019-06-26.18:21:02.865>
    labels = ['interpreter-core', '3.8', 'type-bug', '3.7', '3.9']
    title = 'bytearray.extend does not handle errors during iteration.'
    updated_at = <Date 2019-06-26.22:22:41.667>
    user = 'https://github.com/brandtbucher'

    bugs.python.org fields:

    activity = <Date 2019-06-26.22:22:41.667>
    actor = 'brandtbucher'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-06-26.20:17:31.538>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2019-06-26.18:21:02.865>
    creator = 'brandtbucher'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37417
    keywords = ['patch']
    message_count = 4.0
    messages = ['346655', '346664', '346668', '346677']
    nosy_count = 3.0
    nosy_names = ['serhiy.storchaka', 'miss-islington', 'brandtbucher']
    pr_nums = ['14407', '14408', '14410', '14414']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue37417'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9']

    @brandtbucher
    Copy link
    Member Author

    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.

    @brandtbucher brandtbucher added 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Jun 26, 2019
    @serhiy-storchaka
    Copy link
    Member

    New changeset 2a7d596 by Serhiy Storchaka (Brandt Bucher) in branch 'master':
    bpo-37417: Fix error handling in bytearray.extend. (GH-14407)
    2a7d596

    @SilentGhost SilentGhost mannequin added 3.7 (EOL) end of life 3.8 only security fixes labels Jun 26, 2019
    @miss-islington
    Copy link
    Contributor

    New changeset 7675bca by Miss Islington (bot) in branch '3.7':
    bpo-37417: Fix error handling in bytearray.extend. (GH-14407)
    7675bca

    @miss-islington
    Copy link
    Contributor

    New changeset 5c4ce3e by Miss Islington (bot) in branch '3.8':
    bpo-37417: Fix error handling in bytearray.extend. (GH-14407)
    5c4ce3e

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants