Skip to content

Fix SyntaxError in exception handling for Python 3#14859

Closed
ArnavGarg7 wants to merge 2 commits into
TheAlgorithms:masterfrom
ArnavGarg7:fix-except-syntax
Closed

Fix SyntaxError in exception handling for Python 3#14859
ArnavGarg7 wants to merge 2 commits into
TheAlgorithms:masterfrom
ArnavGarg7:fix-except-syntax

Conversation

@ArnavGarg7

Copy link
Copy Markdown

Describe your change:

This PR fixes SyntaxError: multiple exception types must be parenthesized inside web_programming scripts.

  1. web_programming/fetch_well_rx_price.py: The code was using Python 2 exception syntax (except httpx.HTTPError, ValueError:). Updated it to the correct Python 3 syntax (except (httpx.HTTPError, ValueError):).
  2. web_programming/instagram_crawler.py: Fixed an identical SyntaxError for multiple exception types (except json.decoder.JSONDecodeError, KeyError:). Updated it to except (json.decoder.JSONDecodeError, KeyError):.
  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

@ArnavGarg7 ArnavGarg7 requested a review from cclauss as a code owner June 25, 2026 05:41
Copilot AI review requested due to automatic review settings June 25, 2026 05:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@algorithms-keeper algorithms-keeper Bot added the awaiting reviews This PR is ready to be reviewed label Jun 25, 2026
@cclauss

cclauss commented Jun 25, 2026

Copy link
Copy Markdown
Member

Zero files changed.

@cclauss cclauss closed this Jun 25, 2026
@cclauss

cclauss commented Jun 25, 2026

Copy link
Copy Markdown
Member

An except clause may name multiple exceptions, for example:

... except RuntimeError, TypeError, NameError:
...     pass

https://docs.python.org/3/tutorial/errors.html

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

Labels

awaiting reviews This PR is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants