Skip to content

Bare/Naked exception catching  #62

@mpkocher

Description

@mpkocher

There's a few "naked" or bare exception usage that can yield some difficult to track down bugs.

There's a difference between except: and except Exception. The former is catching SystemExit, KeyboardInterrupt, and GeneratorExit.

https://docs.python.org/3/library/exceptions.html#exception-hierarchy

http://www.wilfred.me.uk/blog/2013/11/03/no-naked-excepts/

Some tooling, such as pylint can help proactively catch some of these potential issues.

$ pylint express | grep -i bare-except
express/parsers/structure.py:92:8: W0702: No exception type(s) specified (bare-except)
express/parsers/structure.py:96:12: W0702: No exception type(s) specified (bare-except)
express/parsers/formats/xml.py:20:12: W0702: No exception type(s) specified (bare-except)
express/parsers/apps/vasp/parser.py:128:8: W0702: No exception type(s) specified (bare-except)
express/parsers/apps/espresso/parser.py:331:12: W0702: No exception type(s) specified (bare-except)
express/properties/material.py:66:8: W0702: No exception type(s) specified (bare-except)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions