Skip to content

Commit c963edb

Browse files
authored
Deprecation and removals (#1240)
- Deprecate `db` and `passwd` again - Remove deprecated error classes in Cursor class attributes.
1 parent af6b9b4 commit c963edb

2 files changed

Lines changed: 4 additions & 33 deletions

File tree

pymysql/connections.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,12 @@ def __init__(
217217
db=None, # deprecated
218218
):
219219
if db is not None and database is None:
220-
# We will raise warning in 2022 or later.
221-
# See https://github.com/PyMySQL/PyMySQL/issues/939
222-
# warnings.warn("'db' is deprecated, use 'database'", DeprecationWarning, 3)
220+
warnings.warn("'db' is deprecated, use 'database'", DeprecationWarning, 3)
223221
database = db
224222
if passwd is not None and not password:
225-
# We will raise warning in 2022 or later.
226-
# See https://github.com/PyMySQL/PyMySQL/issues/939
227-
# warnings.warn(
228-
# "'passwd' is deprecated, use 'password'", DeprecationWarning, 3
229-
# )
223+
warnings.warn(
224+
"'passwd' is deprecated, use 'password'", DeprecationWarning, 3
225+
)
230226
password = passwd
231227

232228
if compress or named_pipe:

pymysql/cursors.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import re
2-
import warnings
32
from . import err
43

54

@@ -362,30 +361,6 @@ def __next__(self):
362361
raise StopIteration
363362
return row
364363

365-
def __getattr__(self, name):
366-
# DB-API 2.0 optional extension says these errors can be accessed
367-
# via Connection object. But MySQLdb had defined them on Cursor object.
368-
if name in (
369-
"Warning",
370-
"Error",
371-
"InterfaceError",
372-
"DatabaseError",
373-
"DataError",
374-
"OperationalError",
375-
"IntegrityError",
376-
"InternalError",
377-
"ProgrammingError",
378-
"NotSupportedError",
379-
):
380-
# Deprecated since v1.1
381-
warnings.warn(
382-
"PyMySQL errors hould be accessed from `pymysql` package",
383-
DeprecationWarning,
384-
stacklevel=2,
385-
)
386-
return getattr(err, name)
387-
raise AttributeError(name)
388-
389364

390365
class DictCursorMixin:
391366
# You can override this to use OrderedDict or other dict-like types.

0 commit comments

Comments
 (0)