Issue 22961: ctypes.WinError & OSError (original) (raw)

Issue22961

Created on 2014-11-28 06:37 by simonzack, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg231796 - (view) Author: Simon Zack (simonzack) Date: 2014-11-28 06:37
The ctypes.WinError function returns: OSError(None, descr, None, code) However OSError does not appear to allow None as a first argument, and converts it to 22 which is the EINVAL "Invalid Argument" error. This is rather confusing as there was no invalid argument errors in the code. I think the behaviour for one of WinError and OSError should be modified so that the handling of errno is more compatible.
msg231805 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2014-11-28 11:06
No, OSError.errno is converted from the Windows error code. There is a translation map (see PC/errmap.h, built with the _dosmaperr() function) and the default value is EINVAL. It's working as intended. What was the winerror code? do you think it should be mapped to another errno?
msg231806 - (view) Author: Simon Zack (simonzack) Date: 2014-11-28 11:28
Ok, my bad, I was creating my own OSErrors so I was just testing it out. I just found the default to be rather confusing as I thought None would not be mapped to anything.
msg231823 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2014-11-28 19:10
> the default value is EINVAL. Should that be specified in the docs? Currently it states that "[t]he errno attribute is then an approximate translation, in POSIX terms, of that native error code". https://docs.python.org/3/library/exceptions.html#OSError
History
Date User Action Args
2022-04-11 14:58:10 admin set github: 67150
2021-02-23 11:28:38 eryksun set status: open -> closedresolution: not a bugstage: resolved
2014-11-28 19:10:02 eryksun set nosy: + eryksunmessages: +
2014-11-28 11:28:22 simonzack set messages: +
2014-11-28 11:06:43 amaury.forgeotdarc set messages: +
2014-11-28 08:15:37 ned.deily set nosy: + amaury.forgeotdarc, belopolsky, meador.inge
2014-11-28 06:37:43 simonzack set components: + ctypesversions: + Python 3.4
2014-11-28 06:37:34 simonzack create