homepage

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.

classification
Title: ctypes.WinError & OSError
Type: Stage: resolved
Components: ctypes Versions: Python 3.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, belopolsky, eryksun, meador.inge, simonzack
Priority: normal Keywords:

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:10adminsetgithub: 67150
2021年02月23日 11:28:38eryksunsetstatus: open -> closed
resolution: not a bug
stage: resolved
2014年11月28日 19:10:02eryksunsetnosy: + eryksun
messages: + msg231823
2014年11月28日 11:28:22simonzacksetmessages: + msg231806
2014年11月28日 11:06:43amaury.forgeotdarcsetmessages: + msg231805
2014年11月28日 08:15:37ned.deilysetnosy: + amaury.forgeotdarc, belopolsky, meador.inge
2014年11月28日 06:37:43simonzacksetcomponents: + ctypes
versions: + Python 3.4
2014年11月28日 06:37:34simonzackcreate

AltStyle によって変換されたページ (->オリジナル) /