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.

Author eryksun
Recipients eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Date 2019-07-30.18:35:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1564511710.04.0.447667243947.issue37705@roundup.psfhosted.org>
In-reply-to
Content
Special casing of Winsock error codes should be handled in winerror_to_errno rather than in oserror_parse_args, so it's consistently applied everywhere. And it should use the proper range for Winsock, 10000-11999 -- not 10000-2147483647. Codes above the Winsock range should map to EINVAL. It's not a non-issue since this range has the following blocks allocated:

    IPSEC     13000-13999
    SXS       14000-14999
    EVT       15000-15079
    EC        15080-15099
    MUI       15100-15199
    MCA       15200-15249
    SYSPART   15250-15299
    VORTEX    15300-15320
    GPIO      15321-15340
    RUNLEVEL  15400-15500
    COMTASK   15501-15510
    APPX      15600-15699
    APPMODEL  15700-15720
    APPXSTATE 15800-15840
    API       15841-15860
    STORE     15861-15880

Another thing winerror_to_errno should do is unwrap HRESULT codes for Win32 errors (0x80070000-0x8007FFFF). In other words, 0x80070005 is effectively the same as ERROR_ACCESS_DENIED (5). It should be mapped to EACCES and raise PermissionError.

For example:

    int
    winerror_to_errno(int winerror)
    {
        /* Unwrap FACILITY_WIN32 HRESULT errors. */
        if ((winerror & 0xFFFF0000) == 0x80070000) {
            winerror &= 0x0000FFFF;
        }

        /* Winsock error codes (10000-11999) are errno values. */
        if (winerror >= 10000 && winerror < 12000) {
            return winerror;
        }

        switch(winerror) {
        
        /* ... */
        
        }
    }
History
Date User Action Args
2019-07-30 18:35:10eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower
2019-07-30 18:35:10eryksunsetmessageid: <1564511710.04.0.447667243947.issue37705@roundup.psfhosted.org>
2019-07-30 18:35:10eryksunlinkissue37705 messages
2019-07-30 18:35:09eryksuncreate