Skip to content

False-positive unreachable code #8567

Open
@dolik-rce

Description

@dolik-rce

Bug description

import signal
import sys

def handle_signal():
    signal.signal(signal.SIGINT, lambda sig, frame: [print("Aborted using CTRL+C"), sys.exit(1)])
    print("Signal handler installed.")

Configuration

No response

Command used

python3 -m pylint a.py

Pylint output

************* Module test
test.py:6:4: W0101: Unreachable code (unreachable)

Expected behavior

No warning should be emitted, because the "unreachable" code is actually called when executed.

Pylint version

pylint 2.17.2
astroid 2.15.2
Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110]

It did work before I upgraded, at least with this version: 

pylint 2.15.4
astroid 2.12.11
Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110]

OS / Environment

Debian 11.3, bash 5.1.4

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationRegressiondirect parentage assumption

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions