fix: parenthesize multiple exception types for Python 3 compatibility - #14989
Closed
zeeshanzzz788 wants to merge 2 commits into
Closed
fix: parenthesize multiple exception types for Python 3 compatibility#14989zeeshanzzz788 wants to merge 2 commits into
zeeshanzzz788 wants to merge 2 commits into
Conversation
except A, B: is Python 2 syntax and raises SyntaxError on Python 3. Restore the parenthesized form except (A, B): in all modules broken by a ruff rewrite so they import and run again. Fixes TheAlgorithms#14929
for more information, see https://pre-commit.ci
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your change:
Several modules currently use invalid Python 3 syntax:
This is Python 2 syntax. In Python 3, multiple exception types must be parenthesized:
Without the parentheses, importing these modules fails immediately with:
This was introduced by a ruff rewrite (see discussion on #14929). This PR restores valid Python 3 syntax in all 12 affected files, not only
maths/greatest_common_divisor.py.Files fixed:
maths/greatest_common_divisor.pydigital_image_processing/filters/local_binary_pattern.pydivide_and_conquer/convex_hull.pydynamic_programming/catalan_numbers.pyproject_euler/problem_002/sol4.pyproject_euler/problem_003/sol1.pyproject_euler/problem_003/sol2.pyproject_euler/problem_003/sol3.pyproject_euler/problem_005/sol1.pyproject_euler/problem_007/sol2.pyweb_programming/fetch_well_rx_price.pyweb_programming/instagram_crawler.pyVerification:
ast.parsepython3 -m doctest maths/greatest_common_divisor.py— 18 passedChecklist:
returntype hint.