Skip to content

'try-except-raise' warnings on 3.9 but not 3.7 #5884

@RemiCardona

Description

@RemiCardona

Bug description

import asyncio

async def coro():
    try:
        await asyncio.sleep(0.5)
    except asyncio.CancelledError:
        raise
    except ValueError:
        pass

No warning raised when running in a python 3.7 venv, W0706(try-except-raise) warning raised with an identical pylint call when running in a 3.9 venv.

# pylint: disable=try-except-raise,useless-suppression thus needed to make pylint happy on both 3.7 and 3.9.

Configuration

No response

Command used

pylint demo.py

Pylint output

************* Module bluelink.demo
demo.py:7: [W0706(try-except-raise), coro] The except handler raises immediately

Expected behavior

No warning raised, as on 3.7. It's a false positive.

Pylint version

pylint 2.12.2
astroid 2.9.3
Python 3.7.12 (default, Mar  8 2022, 11:09:12) 
[GCC 11.2.1 20220115]

and

pylint 2.12.2
astroid 2.9.3
Python 3.9.10 (main, Mar  8 2022, 11:00:59) 
[GCC 11.2.1 20220115]

OS / Environment

~amd64 Gentoo (outputs above) and Debian Buster (with different python patch-level versions)

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions