classification
Title: There is a constant definition error in errno.py
Type: behavior Stage: resolved
Components: Library (Lib), macOS Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: lktoken, ned.deily, ronaldoussoren, xtreak
Priority: normal Keywords:

Created on 2018-07-18 07:26 by lktoken, last changed 2018-07-19 19:26 by brett.cannon. This issue is now closed.

Files
File name Uploaded Description Edit
pythonbug.png lktoken, 2018-07-18 07:26 Screenshot of the error section
Messages (8)
msg321863 - (view) Author: lktoken (lktoken) Date: 2018-07-18 07:26
In errno.py, the constant EDEADLK has a defined value of 11, and the constant EAGAIN has a defined value of 35, which is exactly the opposite of the linux constant definition. See: https://www.thegeekstuff.com/2010/10/linux -error-codes/.
msg321871 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-07-18 09:39
Can you please add some info on how the errorcode dictionary is generated as shown in the picture along with your OS, system information? They seem to have the right values as per the Linux error codes in my Ubuntu box. I might be wrong on the OS on which this happens since you have mentioned it's the opposite of Linux.

cpython git:(master) ✗ rlwrap ./python
Python 3.8.0a0 (heads/master:35c0809, Jul 16 2018, 10:29:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import errno
>>> errno.EDEADLK
35
>>> errno.EAGAIN
11

➜  cpython git:(master) ✗ rlwrap python2.7
Python 2.7.12 (default, Dec  4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import errno
>>> errno.EDEADLK
35
>>> errno.EAGAIN
11

Machine details and values in header files as below

➜  cpython git:(master) ✗ rg 'EDEADLK|EAGAIN' /usr/include/asm-generic/errno-base.h /usr/include/asm-generic/errno.h

/usr/include/asm-generic/errno-base.h
14:#define	EAGAIN		11	/* Try again */

/usr/include/asm-generic/errno.h
6:#define	EDEADLK		35	/* Resource deadlock would occur */

➜  cpython git:(master) ✗ uname -a
Linux ubuntu-s-1vcpu-1gb-blr1-01 4.4.0-127-generic #153-Ubuntu SMP Sat May 19 10:58:46 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux


Thanks
msg321872 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-07-18 09:53
Please ignore about how it's generated. I tried `errno.errorcode` and can get the dictionary as in the picture with https://docs.python.org/3.8/library/errno.html#errno.errorcode. I think this has to be used as below and also would like to know how other error names have the correct numeric value except for the EDEADLK and EAGAIN which is generated at Modules/errnomodule.c . Using them with `os.strerror` also gets me the correct information 

➜  cpython git:(master) ✗ rlwrap ./python
Python 3.8.0a0 (heads/master:35c0809, Jul 16 2018, 10:29:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.strerror(35)
'Resource deadlock avoided'
>>> os.strerror(11)
'Resource temporarily unavailable'

Thanks
msg321932 - (view) Author: lktoken (lktoken) Date: 2018-07-19 07:16
The picture is a screenshot from the IDEA editor on my OSX system. This may be just a problem with the python I am using. So sad.
Python 2.7.10 (default, Oct  6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import errno
>>> errno.EDEADLK
11
>>> errno.EAGAIN
35
>>> import os
>>> os.strerror(11)
'Resource deadlock avoided'
>>> os.strerror(35)
'Resource temporarily unavailable'
>>>

Any more, follow your shell commands, I found this:

➜  ~ grep -E 'EDEADLK|EAGAIN' /usr/include/sys/errno.h
#define	EDEADLK		11		/* Resource deadlock avoided */
					/* 11 was EAGAIN */
#define	EAGAIN		35		/* Resource temporarily unavailable */
#define	EWOULDBLOCK	EAGAIN		/* Operation would block */
 
And my OS info:
➜  ~ uname -a
Darwin lktokendeMacBook-Air.local 17.6.0 Darwin Kernel Version 17.6.0: Tue May  8 15:22:16 PDT 2018; root:xnu-4570.61.1~1/RELEASE_X86_64 x86_64

Thank you very much.
msg321933 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2018-07-19 07:33
I’m not sure if I understand correctly. Is your report about the difference in the values of EAGAIN between Linux and macOS?

If so, that is not a bug: the relevant standards only document the name and type of these constants and not their values. The value can and does vary across operating systems.  

--
On the road, hence brief. 

Op 19 jul. 2018 om 08:16 heeft lktoken <report@bugs.python.org> het volgende geschreven:

> 
> lktoken <zhwbchina@gmail.com> added the comment:
> 
> The picture is a screenshot from the IDEA editor on my OSX system. This may be just a problem with the python I am using. So sad.
> Python 2.7.10 (default, Oct  6 2017, 22:29:07)
> [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import errno
>>>> errno.EDEADLK
> 11
>>>> errno.EAGAIN
> 35
>>>> import os
>>>> os.strerror(11)
> 'Resource deadlock avoided'
>>>> os.strerror(35)
> 'Resource temporarily unavailable'
>>>> 
> 
> Any more, follow your shell commands, I found this:
> 
> ➜  ~ grep -E 'EDEADLK|EAGAIN' /usr/include/sys/errno.h
> #define    EDEADLK        11        /* Resource deadlock avoided */
>                    /* 11 was EAGAIN */
> #define    EAGAIN        35        /* Resource temporarily unavailable */
> #define    EWOULDBLOCK    EAGAIN        /* Operation would block */
> 
> And my OS info:
> ➜  ~ uname -a
> Darwin lktokendeMacBook-Air.local 17.6.0 Darwin Kernel Version 17.6.0: Tue May  8 15:22:16 PDT 2018; root:xnu-4570.61.1~1/RELEASE_X86_64 x86_64
> 
> Thank you very much.
> 
> ----------
> 
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue34143>
> _______________________________________
msg321935 - (view) Author: lktoken (lktoken) Date: 2018-07-19 07:40
yes, I agree that this is not a bug. 
I used to think that this value is the same in macOS and Linux. Now it seems that I am wrong. And sorry for disturbing you.
msg321936 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-07-19 07:52
Thanks for the details @lktoken. I assumed that you were on Linux and had the opposite values. Verified it on my Mac and they report the same values as yours. I think the values are also different for Windows machines as @ronaldoussoren noted in his comment

EAGAIN - 11
EDEADLK - 36 (Not 35 like Linux)

Ref : https://docs.microsoft.com/en-us/cpp/c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr

Thanks
msg321962 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2018-07-19 18:03
This is not a bug and the issue can be closed.  I’ll do so when I get back to my computer in a couple of days. 

--
On the road, hence brief. 

Op 19 jul. 2018 om 08:52 heeft Karthikeyan Singaravelan <report@bugs.python.org> het volgende geschreven:

> 
> Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment:
> 
> Thanks for the details @lktoken. I assumed that you were on Linux and had the opposite values. Verified it on my Mac and they report the same values as yours. I think the values are also different for Windows machines as @ronaldoussoren noted in his comment
> 
> EAGAIN - 11
> EDEADLK - 36 (Not 35 like Linux)
> 
> Ref : https://docs.microsoft.com/en-us/cpp/c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr
> 
> Thanks
> 
> ----------
> 
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue34143>
> _______________________________________
History
Date User Action Args
2018-07-19 19:26:29brett.cannonsetstatus: open -> closed
resolution: not a bug
stage: resolved
2018-07-19 18:03:00ronaldoussorensetmessages: + msg321962
2018-07-19 07:52:37xtreaksetmessages: + msg321936
2018-07-19 07:40:45lktokensetmessages: + msg321935
2018-07-19 07:33:21ronaldoussorensetmessages: + msg321933
2018-07-19 07:16:50lktokensetmessages: + msg321932
2018-07-18 09:53:30xtreaksetmessages: + msg321872
2018-07-18 09:39:06xtreaksetnosy: + xtreak
messages: + msg321871
2018-07-18 07:26:34lktokencreate