Commit b7255d3
authored
Improved exception handling when importing the module (#596)
The current expection handling is too vague, and in certain
circumstances, the error message may confuse the user.
For example, if an error occurs while importing the "_mysql" module, the
original error message is as follows:
```
File "MySQLdb/__init__.py", line 18, in <module>
from . import _mysql
ImportError: /lib64/libstdc++.so.6: cannot allocate memory in static TLS block
```
But on the user side, he can only see the exception message like this:
```
/MySQLdb/__init__.py", line 24, in <module>
version_info, _mysql.version_info, _mysql.__file__
NameError: name '_mysql' is not defined
```
This PR fixes this issue by making the exception handling statements
more precise.1 parent 1f4fb4d commit b7255d3
1 file changed
+4
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
| |||
0 commit comments