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

Check for tp_iter in ceval:ext_do_call before overriding exception message #49468

Closed
gpolo mannequin opened this issue Feb 11, 2009 · 7 comments
Closed

Check for tp_iter in ceval:ext_do_call before overriding exception message #49468

gpolo mannequin opened this issue Feb 11, 2009 · 7 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@gpolo
Copy link
Mannequin

gpolo mannequin commented Feb 11, 2009

BPO 5218
Nosy @birkenfeld, @terryjreedy, @pitrou, @vadmium
Superseder
  • bpo-4806: Function calls taking a generator as star argument can mask TypeErrors in the generator
  • Files
  • check_before_overriding.diff
  • 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 2012-02-04.02:27:29.818>
    created_at = <Date 2009-02-11.19:32:42.634>
    labels = ['interpreter-core', 'type-bug']
    title = 'Check for tp_iter in ceval:ext_do_call before overriding exception message'
    updated_at = <Date 2012-02-04.02:27:29.815>
    user = 'https://bugs.python.org/gpolo'

    bugs.python.org fields:

    activity = <Date 2012-02-04.02:27:29.815>
    actor = 'terry.reedy'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-02-04.02:27:29.818>
    closer = 'terry.reedy'
    components = ['Interpreter Core']
    creation = <Date 2009-02-11.19:32:42.634>
    creator = 'gpolo'
    dependencies = []
    files = ['13037']
    hgrepos = []
    issue_num = 5218
    keywords = ['patch']
    message_count = 7.0
    messages = ['81657', '81658', '81659', '81675', '119296', '151111', '152581']
    nosy_count = 5.0
    nosy_names = ['georg.brandl', 'terry.reedy', 'pitrou', 'gpolo', 'martin.panter']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '4806'
    type = 'behavior'
    url = 'https://bugs.python.org/issue5218'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3']

    @gpolo
    Copy link
    Mannequin Author

    gpolo mannequin commented Feb 11, 2009

    Hi,

    I find it weird that given this sample code:

    def g():
        yield iter(None)
    list(*g())

    I get this traceback:

    Traceback (most recent call last):
      File "a1.py", line 3, in <module>
        list(*g())
    TypeError: type object argument after * must be a sequence, not generator

    At a minimum the exception message looks awkward to me. With the
    proposed patch, the new traceback would be:

    Traceback (most recent call last):
      File "a1.py", line 3, in <module>
        list(*g())
      File "a1.py", line 2, in g
        yield iter(None)
    TypeError: 'NoneType' object is not iterable

    @gpolo gpolo mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Feb 11, 2009
    @gpolo
    Copy link
    Mannequin Author

    gpolo mannequin commented Feb 11, 2009

    (Btw, the suggestion to check for tp_iter came from Antoine Pitrou. It
    seemed fine to me.)

    @pitrou
    Copy link
    Member

    pitrou commented Feb 11, 2009

    You must check tp_iter as well, not only Py_TPFLAGS_HAVE_ITER.
    Py_TPFLAGS_HAVE_ITER only tells you that the tp_iter field exists, not
    that it's non-NULL.
    (see the code for PyObject_GetIter() in Objects/abstract.c for an example)

    @gpolo
    Copy link
    Mannequin Author

    gpolo mannequin commented Feb 11, 2009

    Thanks for taking a look, my bad for taking so long to reply.

    I'm adding a new patch now. This one, besides the fix needed mentioned
    above, disregards tp_iter from old class instances (since they are
    always available and tell us nothing).

    @birkenfeld
    Copy link
    Member

    Is this ready to commit?

    @pitrou pitrou removed their assignment Dec 15, 2010
    @vadmium
    Copy link
    Member

    vadmium commented Jan 12, 2012

    See also bpo-4806

    @terryjreedy
    Copy link
    Member

    This is one of 4 duplicate issues, 3 with somewhat similar patches, with nearly disjoint nosy lists. Consolidating.

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

    4 participants