Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a constant definition error in errno.py #78324

Closed
lktoken mannequin opened this issue Jul 18, 2018 · 8 comments
Closed

There is a constant definition error in errno.py #78324

lktoken mannequin opened this issue Jul 18, 2018 · 8 comments
Labels
OS-mac stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@lktoken
Copy link
Mannequin

lktoken mannequin commented Jul 18, 2018

BPO 34143
Nosy @ronaldoussoren, @ned-deily, @tirkarthi, @lktoken
Files
  • pythonbug.png: Screenshot of the error section
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2018-07-19.19:26:29.869>
    created_at = <Date 2018-07-18.07:26:34.228>
    labels = ['OS-mac', 'invalid', 'type-bug', 'library']
    title = 'There is a constant definition error in errno.py'
    updated_at = <Date 2018-07-19.19:26:29.868>
    user = 'https://github.com/lktoken'

    bugs.python.org fields:

    activity = <Date 2018-07-19.19:26:29.868>
    actor = 'brett.cannon'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-07-19.19:26:29.869>
    closer = 'brett.cannon'
    components = ['Library (Lib)', 'macOS']
    creation = <Date 2018-07-18.07:26:34.228>
    creator = 'lktoken'
    dependencies = []
    files = ['47703']
    hgrepos = []
    issue_num = 34143
    keywords = []
    message_count = 8.0
    messages = ['321863', '321871', '321872', '321932', '321933', '321935', '321936', '321962']
    nosy_count = 4.0
    nosy_names = ['ronaldoussoren', 'ned.deily', 'xtreak', 'lktoken']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue34143'
    versions = ['Python 2.7']

    @lktoken
    Copy link
    Mannequin Author

    lktoken mannequin commented Jul 18, 2018

    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/.

    @lktoken lktoken mannequin added stdlib Python modules in the Lib dir OS-mac type-bug An unexpected behavior, bug, or error labels Jul 18, 2018
    @tirkarthi
    Copy link
    Member

    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

    @tirkarthi
    Copy link
    Member

    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

    @lktoken
    Copy link
    Mannequin Author

    lktoken mannequin commented Jul 19, 2018

    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.

    @ronaldoussoren
    Copy link
    Contributor

    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\>


    @lktoken
    Copy link
    Mannequin Author

    lktoken mannequin commented Jul 19, 2018

    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.

    @tirkarthi
    Copy link
    Member

    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

    @ronaldoussoren
    Copy link
    Contributor

    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\>


    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    OS-mac stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants