This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Switch constants in the errno module to IntEnum
Type: enhancement Stage:
Components: Extension Modules, Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: barry, chrishood, eli.bendersky, ethan.furman, lemburg, pitrou, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2013-11-16 12:21 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (11)
msg203035 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-16 12:21
It will be good to switch constants in the errno module to IntEnum.
msg204394 - (view) Author: Chris (chrishood) Date: 2013-11-25 20:16
I would be interested in tackling this as a first patch, can you give me some more information?
msg204395 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2013-11-25 20:24
Check out socket.py for an example of constants being changed over to IntEnum.

Feel free to ask more questions!  :)
msg204398 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2013-11-25 20:26
Also see Issue18720 for those details.
msg204400 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-25 20:28
This is not so easy issue because the errno module is not pure Python module. ;)
msg204409 - (view) Author: Chris (chrishood) Date: 2013-11-25 21:19
I think I'll look for some other issues, this one looks a bit deep for a first patch.
msg204482 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-11-26 15:07
I don't know if it's possible/convinient, but it would be nice to have a str() method using os.strerror(). Or maybe a method with a different name.
msg204493 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-11-26 15:45
> This is not so easy issue because the errno module is not pure Python module. ;)

An option is to rename the C errno module to _errno and leave it unchanged, and provide a Python errno module which enum API.

Then slowly errno module should be used instead of _errno.

Using enum for errno should not slow down Python startup time.
msg204662 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-11-28 14:39
> An option is to rename the C errno module to _errno and leave it
> unchanged, and provide a Python errno module which enum API.

I agree it sounds reasonable.

> Using enum for errno should not slow down Python startup time.

enum imports OrderedDict from collections, which imports other modules...
msg204663 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-11-28 14:40
Note that even if errno is migrated to enum, OSErrors raised by the interpreter will still have a raw int errno...
msg204666 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2013-11-28 14:48
I'm not sure whether changing the errno module to use enums would be conceptually correct:

enums declare a fixed set of permitted values, but errno values can be any integer, are platform dependent and are sometimes not unique (e.g. EWOULDBLOCK = EAGAIN, or the various Windows WSA errno values which map to similar integers as the Unix ones).
History
Date User Action Args
2022-04-11 14:57:53adminsetgithub: 63823
2015-07-21 08:10:01ethan.furmansetstatus: open -> closed
resolution: rejected
stage: needs patch ->
2013-11-28 14:48:57lemburgsetnosy: + lemburg
messages: + msg204666
2013-11-28 14:40:34pitrousetmessages: + msg204663
2013-11-28 14:39:26pitrousetnosy: + pitrou
messages: + msg204662
2013-11-26 16:49:30eli.benderskysetkeywords: - easy
2013-11-26 15:45:39vstinnersetmessages: + msg204493
2013-11-26 15:07:28vstinnersetnosy: + vstinner
messages: + msg204482
2013-11-25 21:19:29chrishoodsetmessages: + msg204409
2013-11-25 20:28:04serhiy.storchakasetmessages: + msg204400
2013-11-25 20:26:07ethan.furmansetmessages: + msg204398
2013-11-25 20:24:28ethan.furmansetmessages: + msg204395
2013-11-25 20:16:32chrishoodsetnosy: + chrishood
messages: + msg204394
2013-11-25 03:24:17ezio.melottisetkeywords: + easy
type: enhancement
versions: + Python 3.5, - Python 3.4
2013-11-16 12:21:47serhiy.storchakacreate