[Python-Dev] Deprecate invalid ctypes call protection on Windows

Victor Stinner victor.stinner at gmail.com
Tue May 23 15:12:32 EDT 2017


2017-05-22 13:17 GMT-05:00 Steve Dower <steve.dower at python.org>:
> Once the special protection is removed, most of these cases will become
> OSError due to the general protection against segmentation faults.

It didn't know that ctypes on Windows had a special protection against
programming errors. I'm not aware of such protection Linux. If you
call a function with the wrong number of arguments, it's likely to
crash or return random data.

I guess that the point is to help debugging. But since Python 3.6,
faulthandler now registers a Windows exception handler and so it able
to dump the Python traceback on any Windows exception:
https://docs.python.org/dev/library/faulthandler.html#faulthandler.enable

So I think that it's now fine to remove the ctypes protection. Just
advice (remind? ;-)) users to enable faulthandler: python3 -X
faulthandler, or call faulthandler.enable(). (You might want to use a
log file for that on Windows, depends on the use case.)


More information about the Python-Dev mailing list