Skip to content

fix: replace 4 bare except clauses with except Exception in jsdate.py#345

Open
koteshyelamati wants to merge 1 commit into
PiotrDabkowski:masterfrom
koteshyelamati:patch-2
Open

fix: replace 4 bare except clauses with except Exception in jsdate.py#345
koteshyelamati wants to merge 1 commit into
PiotrDabkowski:masterfrom
koteshyelamati:patch-2

Conversation

@koteshyelamati

Copy link
Copy Markdown

Bare except: clauses catch BaseException, including SystemExit and KeyboardInterrupt.

In jsdate.py, 4 bare except: clauses wrap datetime conversion and formatting calls:

  • to_local_dt() and to_utc_dt() can raise OverflowError (out-of-range dates), OSError (pre-1970 dates on Windows), or ValueError
  • dt.strftime(pattern) can raise ValueError for unsupported patterns or UnicodeEncodeError

All four convert any exception into a JavaScript-style MakeError('TypeError', ...). Using except Exception: correctly covers all these cases while still allowing KeyboardInterrupt and SystemExit to propagate.

Updated exception handling to specify Exception type.
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.

1 participant