Skip to content

deprecate exception classes in Cursor attributes#782

Merged
methane merged 3 commits into
PyMySQL:mainfrom
methane:deprecate-warnings
Jun 10, 2026
Merged

deprecate exception classes in Cursor attributes#782
methane merged 3 commits into
PyMySQL:mainfrom
methane:deprecate-warnings

Conversation

@methane

@methane methane commented Jun 10, 2026

Copy link
Copy Markdown
Member

No description provided.

@methane methane requested a review from Copilot June 10, 2026 06:18
@methane methane linked an issue Jun 10, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR deprecates accessing DB-API exception classes via Cursor attributes by replacing the existing cursor-level exception attributes with a BaseCursor.__getattr__ fallback that emits a DeprecationWarning and forwards lookups to the underlying exceptions module.

Changes:

  • Remove cursor-level exception attributes previously defined on BaseCursor.
  • Add BaseCursor.__getattr__ to intercept exception attribute access and emit a deprecation warning.
  • Forward exception attribute lookups to MySQLdb._exceptions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/MySQLdb/cursors.py Outdated
Comment thread src/MySQLdb/cursors.py Outdated
Comment thread src/MySQLdb/cursors.py Outdated
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.75%. Comparing base (e2a908b) to head (11dc0c9).
⚠️ Report is 37 commits behind head on main.

Files with missing lines Patch % Lines
src/MySQLdb/cursors.py 14.28% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #782      +/-   ##
==========================================
- Coverage   88.86%   88.75%   -0.12%     
==========================================
  Files           7        7              
  Lines         548      560      +12     
==========================================
+ Hits          487      497      +10     
- Misses         61       63       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@methane methane merged commit 63e67ad into PyMySQL:main Jun 10, 2026
9 of 11 checks passed
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.

Deprecate Exceptions in Cursor

2 participants