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

Raise a Py3K warning for catching nested tuples with non-BaseException exceptions #46633

Closed
abalkin opened this issue Mar 18, 2008 · 5 comments
Closed
Labels
easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@abalkin
Copy link
Member

abalkin commented Mar 18, 2008

BPO 2380
Nosy @abalkin, @pitrou, @benjaminp, @ezio-melotti, @zware
Files
  • issue2380.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 2020-05-04.13:55:06.718>
    created_at = <Date 2008-03-18.03:51:02.944>
    labels = ['interpreter-core', 'easy', 'type-bug']
    title = 'Raise a Py3K warning for catching nested tuples with non-BaseException exceptions'
    updated_at = <Date 2020-05-04.13:55:06.715>
    user = 'https://github.com/abalkin'

    bugs.python.org fields:

    activity = <Date 2020-05-04.13:55:06.715>
    actor = 'zach.ware'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-05-04.13:55:06.718>
    closer = 'zach.ware'
    components = ['Interpreter Core']
    creation = <Date 2008-03-18.03:51:02.944>
    creator = 'belopolsky'
    dependencies = []
    files = ['9720']
    hgrepos = []
    issue_num = 2380
    keywords = ['patch', 'easy', '26backport']
    message_count = 5.0
    messages = ['63875', '66580', '123030', '123248', '368051']
    nosy_count = 6.0
    nosy_names = ['belopolsky', 'pitrou', 'benjamin.peterson', 'brunogola', 'ezio.melotti', 'zach.ware']
    pr_nums = []
    priority = 'low'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue2380'
    versions = []

    @abalkin
    Copy link
    Member Author

    abalkin commented Mar 18, 2008

    As of r61478, the following code fails to produce a py3k warning:

    try:
    raise ValueError
    except ((ValueError,object),):
    pass

    which is an error for in py3k:

    Traceback (most recent call last):
      File "x.py", line 3, in <module>
        except ((ValueError,object),):
    TypeError: catching classes that do not inherit from BaseException is 
    not allowed

    @abalkin abalkin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Mar 18, 2008
    @brunogola
    Copy link
    Mannequin

    brunogola mannequin commented May 10, 2008

    Should nested tuples in an except clause be a valid syntax?
    like:
    ...
    except ((ValueError, Exception), TypeError, (...)):
    pass

    I don't see any benefit and because of this behavior the implementation
    (in Python/errors.c and in the patch attached) will use recursive function.

    I think that any objects inside a tuple in an except clause should be
    treated equally (as an object), even a tuple, so the except clause above
    should be an error in py3k and should produce a warning because the list
    objects does not inherits BaseException.

    Please, see my comment in http://bugs.python.org/issue2345, it is
    related to this issue.

    @abalkin
    Copy link
    Member Author

    abalkin commented Dec 2, 2010

    bpo-2380.diff does not apply anymore.

    @abalkin abalkin self-assigned this Dec 2, 2010
    @pitrou
    Copy link
    Member

    pitrou commented Dec 3, 2010

    Not all incompatibilities have to raise a py3k warnings; AFAIK, only those which are not handled by 2to3 do.

    @abalkin abalkin removed their assignment Sep 10, 2016
    @zware
    Copy link
    Member

    zware commented May 4, 2020

    With 2.7 out of support, closing.

    @zware zware closed this as completed May 4, 2020
    @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
    easy 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