Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[py] Fix bare exception #15465

Merged
merged 1 commit into from
Mar 20, 2025
Merged

Conversation

cgoldberg
Copy link
Contributor

@cgoldberg cgoldberg commented Mar 20, 2025

User description

Motivation and Context

Fix a bare exception that broke linting.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Bug fix


Description

  • Replaced a bare exception with Exception in is_connectable.

  • Improved code clarity and adherence to linting standards.


Changes walkthrough 📝

Relevant files
Bug fix
utils.py
Replace bare exception with `Exception` in `is_connectable`

py/selenium/webdriver/common/utils.py

  • Replaced a bare exception with Exception.
  • Enhanced error handling in the finally block.
  • +1/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ No major issues detected

    @cgoldberg cgoldberg merged commit db1223d into SeleniumHQ:trunk Mar 20, 2025
    4 checks passed
    @cgoldberg cgoldberg deleted the py-fix-exception branch March 20, 2025 18:42
    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Learned
    best practice
    Catch specific exception types rather than generic Exception to improve code clarity and maintainability

    While replacing a bare except: with except Exception: is an improvement, it's
    still too generic. It's better to catch specific exceptions that might occur
    during socket shutdown, such as socket.error or OSError. This makes the code
    more maintainable and helps with debugging by being explicit about what errors
    are expected and safely ignored.

    py/selenium/webdriver/common/utils.py [107-110]

     try:
         socket_.shutdown(socket.SHUT_RDWR)
    -except Exception:
    +except (socket.error, OSError):
         pass
    • Apply this suggestion
    Suggestion importance[1-10]: 6
    Low
    • More

    sandeepsuryaprasad pushed a commit to sandeepsuryaprasad/selenium that referenced this pull request Mar 23, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant