[Django] #30137: Replace use of OSError aliases with OSError (IOError, EnvironmentError, WindowsError, mmap.error, socket.error, select.error)

32 views
Skip to first unread message

Django

unread,
Jan 26, 2019, 7:58:15 PM1/26/19
to django-...@googlegroups.com
#30137: Replace use of OSError aliases with OSError (IOError, EnvironmentError,
WindowsError, mmap.error, socket.error, select.error)
------------------------------------------------+------------------------
Reporter: Jon Dufresne | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
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.error` or `select.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 `OSError` that is the base exception class for all the other
exceptions provided by this module.
>
> Changed in version 3.4: SMTPException became subclass of OSError

--
Ticket URL: <https://code.djangoproject.com/ticket/30137>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 26, 2019, 8:02:21 PM1/26/19
to django-...@googlegroups.com
#30137: Replace use of OSError aliases with OSError (IOError, EnvironmentError,
WindowsError, mmap.error, socket.error, select.error)
-------------------------------------+-------------------------------------

Reporter: Jon Dufresne | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Uncategorized | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jon Dufresne):

* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/10904

--
Ticket URL: <https://code.djangoproject.com/ticket/30137#comment:1>

Django

unread,
Jan 26, 2019, 10:23:01 PM1/26/19
to django-...@googlegroups.com
#30137: Replace use of OSError aliases with OSError (IOError, EnvironmentError,
WindowsError, mmap.error, socket.error, select.error)
--------------------------------------+------------------------------------

Reporter: Jon Dufresne | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Nick Pope):

* stage: Unreviewed => Accepted


Comment:

Now we're targeting Python ≥ 3.6 for Django 3.0 this is a nice clean up.

--
Ticket URL: <https://code.djangoproject.com/ticket/30137#comment:2>

Django

unread,
Jan 27, 2019, 1:38:13 PM1/27/19
to django-...@googlegroups.com
#30137: Replace use of OSError aliases with OSError (IOError, EnvironmentError,
WindowsError, mmap.error, socket.error, select.error)
-------------------------------------+-------------------------------------

Reporter: Jon Dufresne | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Uncategorized | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/30137#comment:3>

Django

unread,
Jan 28, 2019, 11:48:18 AM1/28/19
to django-...@googlegroups.com
#30137: Replace use of OSError aliases with OSError (IOError, EnvironmentError,
WindowsError, mmap.error, socket.error, select.error)
-------------------------------------+-------------------------------------

Reporter: Jon Dufresne | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Uncategorized | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"7785e03ba89aafbd949191f126361fb9103cb980" 7785e03b]:
{{{
#!CommitTicketReference repository=""
revision="7785e03ba89aafbd949191f126361fb9103cb980"
Fixed #30137 -- Replaced OSError aliases with the canonical OSError.

Used more specific errors (e.g. FileExistsError) as appropriate.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30137#comment:4>

Django

unread,
Jan 29, 2019, 10:05:48 AM1/29/19
to django-...@googlegroups.com
#30137: Replace use of OSError aliases with OSError (IOError, EnvironmentError,
WindowsError, mmap.error, socket.error, select.error)
-------------------------------------+-------------------------------------

Reporter: Jon Dufresne | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Uncategorized | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"9a0cc54524422dbdd9213e83a8ad7e8a4c13bd3e" 9a0cc54]:
{{{
#!CommitTicketReference repository=""
revision="9a0cc54524422dbdd9213e83a8ad7e8a4c13bd3e"
Refs #30137 -- Fixed template test on Windows.

Broken in 7785e03ba89aafbd949191f126361fb9103cb980.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30137#comment:5>

Reply all
Reply to author
Forward
0 new messages