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

*args unpacking can mask TypeErrors #75254

Closed
pochmann mannequin opened this issue Jul 28, 2017 · 4 comments
Closed

*args unpacking can mask TypeErrors #75254

pochmann mannequin opened this issue Jul 28, 2017 · 4 comments
Assignees
Labels
3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@pochmann
Copy link
Mannequin

pochmann mannequin commented Jul 28, 2017

BPO 31071
Nosy @bitdancer, @serhiy-storchaka, @pochmann
PRs
  • bpo-31071: Avoid masking original TypeError in call with * unpacking #2957
  • [3.6] bpo-31071: Avoid masking original TypeError in call with * unpacking (GH-2957)\ #2991
  • 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 = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2017-08-03.09:18:25.635>
    created_at = <Date 2017-07-28.16:03:22.305>
    labels = ['interpreter-core', 'type-bug', '3.7']
    title = '*args unpacking can mask TypeErrors'
    updated_at = <Date 2017-08-03.09:18:25.634>
    user = 'https://github.com/pochmann'

    bugs.python.org fields:

    activity = <Date 2017-08-03.09:18:25.634>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2017-08-03.09:18:25.635>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2017-07-28.16:03:22.305>
    creator = 'Stefan Pochmann'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31071
    keywords = []
    message_count = 4.0
    messages = ['299402', '299411', '299690', '299694']
    nosy_count = 3.0
    nosy_names = ['r.david.murray', 'serhiy.storchaka', 'Stefan Pochmann']
    pr_nums = ['2957', '2991']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue31071'
    versions = ['Python 3.6', 'Python 3.7']

    @pochmann
    Copy link
    Mannequin Author

    pochmann mannequin commented Jul 28, 2017

    Python 3.6 makes it sound like maps aren't iterable:

    >>> map(str, *map(int, [[]]))
    Traceback (most recent call last):
      File "<pyshell#0>", line 1, in <module>
        map(str, *map(int, [[]]))
    TypeError: type object argument after * must be an iterable, not map

    More, including a likely explanation, in my question and its answer here:
    https://stackoverflow.com/q/45363330/1672429

    Apparently the TypeError from int([]) gets mistaken for a TypeError indicating non-iterability of the map object.

    @pochmann pochmann mannequin added the type-bug An unexpected behavior, bug, or error label Jul 28, 2017
    @bitdancer
    Copy link
    Member

    Thanks for the report. Retitling because this has nothing to do with map:

    >>> def foo(*args):
    ...     raise TypeError('fake')
    ...     yield 1
    ... 
    >>> foo(1, *foo())
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: foo() argument after * must be an iterable, not generator
    >>> foo(*foo())
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "<stdin>", line 2, in foo
    TypeError: fake

    @bitdancer bitdancer added the 3.7 (EOL) end of life label Jul 28, 2017
    @bitdancer bitdancer changed the title Bad error message about maps not iterable *args unpacking can mask TypeErrors Jul 28, 2017
    @serhiy-storchaka serhiy-storchaka added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Jul 31, 2017
    @serhiy-storchaka serhiy-storchaka self-assigned this Jul 31, 2017
    @serhiy-storchaka
    Copy link
    Member

    New changeset 25e4f77 by Serhiy Storchaka in branch 'master':
    bpo-31071: Avoid masking original TypeError in call with * unpacking (bpo-2957)
    25e4f77

    @serhiy-storchaka
    Copy link
    Member

    New changeset 946a0b6 by Serhiy Storchaka in branch '3.6':
    [3.6] bpo-31071: Avoid masking original TypeError in call with * unpacking (GH-2957) (bpo-2991)
    946a0b6

    @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 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

    2 participants