Skip to content

False negative undefined-variable after a caught exception shadowing a variable name #157

@pylint-bot

Description

@pylint-bot

Originally reported by: BitBucket: moxian, GitHub: @moxian?


Pylint'ing snippet

def main():
    exc = None
    try:
        [][1] = 12
    except IndexError as exc:
        pass
    if exc is not None:
        raise exc


main()

says

Raising NoneType while only classes, instances or string are allowed (raising-bad-type)

when in fact None will never be attempted to be raised

Python 2


Metadata

Metadata

Assignees

No one assigned

    Labels

    C: undefined-variableIssues related to 'undefined-variable' checkControl flowRequires control flow understandingFalse Negative 🦋No message is emitted but something is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions