Skip to content

fix: replace bare except with except Exception in image validation functions - #719

Open
Suraj Kumar (surajthedev) wants to merge 1 commit into
microsoft:mainfrom
surajthedev:fix/bare-except-handling
Open

fix: replace bare except with except Exception in image validation functions#719
Suraj Kumar (surajthedev) wants to merge 1 commit into
microsoft:mainfrom
surajthedev:fix/bare-except-handling

Conversation

@surajthedev

Copy link
Copy Markdown

Fixes #707

Description

This PR replaces bare except: clauses with except Exception: in image
validation functions, following Python best practices (PEP 8).

Changes

Replaced bare except: with except Exception: in:

  • lessons/4-ComputerVision/07-ConvNets/tfcv.py
  • lessons/4-ComputerVision/07-ConvNets/pytorchcv.py
  • lessons/4-ComputerVision/08-TransferLearning/tfcv.py
  • lessons/4-ComputerVision/08-TransferLearning/pytorchcv.py

Motivation

Bare except: clauses catch all exceptions, including SystemExit and
KeyboardInterrupt, which can mask serious errors and prevent users from
stopping the program (e.g., via Ctrl+C). Using except Exception: follows
PEP 8 guidelines and prevents masking of critical system exceptions, while
still catching all legitimate errors like corrupt or invalid image files.

Testing

  • Verified syntax correctness with python -m py_compile
  • Maintains the same error handling behavior for legitimate exceptions
  • Allows system-level exceptions (KeyboardInterrupt, SystemExit) to
    propagate properly

@surajthedev

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@surajthedev

Copy link
Copy Markdown
Author

Hi Microsoft (@microsoft), just wanted to kindly follow up on this PR. It has been open for around 2 weeks, and I believe all the requested changes have been completed.
Whenever you get a chance, could you please take a look and let me know if any further changes are needed from my side?
Thank you for your time!

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.

Bare except clauses in image validation functions

2 participants