Skip to content

Commit 6bba231

Browse files
committed
Add __module__ attributes to exception classes.
Fixes #522.
1 parent 5340191 commit 6bba231

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

MySQLdb/_exceptions.py

+11
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,38 @@
88

99
class MySQLError(Exception):
1010
"""Exception related to operation with MySQL."""
11+
__module__ = "MySQLdb"
1112

1213

1314
class Warning(Warning, MySQLError):
1415
"""Exception raised for important warnings like data truncations
1516
while inserting, etc."""
17+
__module__ = "MySQLdb"
1618

1719

1820
class Error(MySQLError):
1921
"""Exception that is the base class of all other error exceptions
2022
(not Warning)."""
23+
__module__ = "MySQLdb"
2124

2225

2326
class InterfaceError(Error):
2427
"""Exception raised for errors that are related to the database
2528
interface rather than the database itself."""
29+
__module__ = "MySQLdb"
2630

2731

2832
class DatabaseError(Error):
2933
"""Exception raised for errors that are related to the
3034
database."""
35+
__module__ = "MySQLdb"
3136

3237

3338
class DataError(DatabaseError):
3439
"""Exception raised for errors that are due to problems with the
3540
processed data like division by zero, numeric value out of range,
3641
etc."""
42+
__module__ = "MySQLdb"
3743

3844

3945
class OperationalError(DatabaseError):
@@ -42,28 +48,33 @@ class OperationalError(DatabaseError):
4248
e.g. an unexpected disconnect occurs, the data source name is not
4349
found, a transaction could not be processed, a memory allocation
4450
error occurred during processing, etc."""
51+
__module__ = "MySQLdb"
4552

4653

4754
class IntegrityError(DatabaseError):
4855
"""Exception raised when the relational integrity of the database
4956
is affected, e.g. a foreign key check fails, duplicate key,
5057
etc."""
58+
__module__ = "MySQLdb"
5159

5260

5361
class InternalError(DatabaseError):
5462
"""Exception raised when the database encounters an internal
5563
error, e.g. the cursor is not valid anymore, the transaction is
5664
out of sync, etc."""
65+
__module__ = "MySQLdb"
5766

5867

5968
class ProgrammingError(DatabaseError):
6069
"""Exception raised for programming errors, e.g. table not found
6170
or already exists, syntax error in the SQL statement, wrong number
6271
of parameters specified, etc."""
72+
__module__ = "MySQLdb"
6373

6474

6575
class NotSupportedError(DatabaseError):
6676
"""Exception raised in case a method or database API was used
6777
which is not supported by the database, e.g. requesting a
6878
.rollback() on a connection that does not support transaction or
6979
has transactions turned off."""
80+
__module__ = "MySQLdb"

0 commit comments

Comments
 (0)