Issue 19624: Switch constants in the errno module to IntEnum (original) (raw)

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:53 admin set github: 63823
2015-07-21 08:10:01 ethan.furman set status: open -> closedresolution: rejectedstage: needs patch ->
2013-11-28 14:48:57 lemburg set nosy: + lemburgmessages: +
2013-11-28 14:40:34 pitrou set messages: +
2013-11-28 14:39:26 pitrou set nosy: + pitroumessages: +
2013-11-26 16:49:30 eli.bendersky set keywords: - easy
2013-11-26 15:45:39 vstinner set messages: +
2013-11-26 15:07:28 vstinner set nosy: + vstinnermessages: +
2013-11-25 21:19:29 chrishood set messages: +
2013-11-25 20:28:04 serhiy.storchaka set messages: +
2013-11-25 20:26:07 ethan.furman set messages: +
2013-11-25 20:24:28 ethan.furman set messages: +
2013-11-25 20:16:32 chrishood set nosy: + chrishoodmessages: +
2013-11-25 03:24:17 ezio.melotti set keywords: + easytype: enhancementversions: + Python 3.5, - Python 3.4
2013-11-16 12:21:47 serhiy.storchaka create