#30137 closed Cleanup/optimization (fixed)
Replace use of OSError aliases with OSError (IOError, EnvironmentError, WindowsError, mmap.error, socket.error, select.error)
| Reported by: | Jon Dufresne | Owned by: | nobody |
|---|---|---|---|
| Component: | Uncategorized | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Starting with Python 3.3, EnvironmentError, IOError, WindowsError, socket.error, select.error and mmap.error are aliases of OSError. With this in mind, the Django code base can be cleaned up.
For additional details, see the Python 3.3 release notes:
https://docs.python.org/3/whatsnew/3.3.html#pep-3151-reworking-the-os-and-io-exception-hierarchy
You don’t have to worry anymore about choosing the appropriate exception type between
OSError,IOError,EnvironmentError,WindowsError,mmap.error,socket.errororselect.error. All these exception types are now only one:OSError. The other names are kept as aliases for compatibility reasons.
Additionally, since Python 3.4, SMTPException is subclass of OSError . So exception handles catching both can be simplified to just OSError.
https://docs.python.org/3/library/smtplib.html#smtplib.SMTPException
Subclass of
OSErrorthat is the base exception class for all the other exceptions provided by this module.
Changed in version 3.4: SMTPException became subclass of OSError
Change History (5)
comment:1 by , 7 years ago
| Has patch: | set |
|---|
comment:2 by , 7 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
Now we're targeting Python ≥ 3.6 for Django 3.0 this is a nice clean up.
comment:3 by , 7 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
https://github.com/django/django/pull/10904