Skip to content

fix: replace bare except clauses with specific exception types#268

Open
koteshyelamati wants to merge 1 commit into
p4lang:mainfrom
koteshyelamati:patch-1
Open

fix: replace bare except clauses with specific exception types#268
koteshyelamati wants to merge 1 commit into
p4lang:mainfrom
koteshyelamati:patch-1

Conversation

@koteshyelamati

Copy link
Copy Markdown

Bare except: clauses catch BaseException, which includes SystemExit, KeyboardInterrupt, and GeneratorExit — signals that should generally propagate. This PR replaces them with specific exception types:

  • except AttributeError: — for string method calls on non-string input in parse_ports()
  • except ValueError: — for int() parsing and range parsing in parse_ports()
  • except ImportError: — for optional pynng import
  • except Exception: — for module imports, platform operations, test execution, and dynamic code execution

No behaviour change for normal flows; only pathological signals (KeyboardInterrupt etc.) are now able to propagate correctly.

Signed-off-by: Kotesh Kumar Yelamati <yelamatikoteshkumar@gmail.com>
@jafingerhut

Copy link
Copy Markdown
Collaborator

There are several unit tests that appear to be failing. Have you tried to analyze those failures to see why they occur, and ideally fix the code changes so that the tests pass? I suppose it is possible that the tests should have been failing before, but were passing for some incorrect reason, but that would take investigation to find out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants