New submission from Thijs Miedema <thijsmiedem...@gmail.com>:

When setting the restype of a ctypes._FuncPtr you can use None to indicate a 
void function. However, I use inspect.signature to dynamically bind python 
functions to a DLL, and that doesn't return None but NoneType if the type hint 
return type is None starting at python 3.10.

This change caused me to set the restype to NoneType, which makes ctypes cause 
a cryptic "TypeError: NoneType takes no arguments" upon returning from a 
successfully executed C function. 

The included example demonstrates the differing results from inspect, a working 
example, a failing example and an example that works in 3.9 but fails in 3.10.

Proposed solution: Treat NoneType as None for ctypes._FuncPtr.restype

----------
components: ctypes
files: minimal_example_ctypes_nonetype_behaviour.py
messages: 386867
nosy: thijsmiedema94
priority: normal
severity: normal
status: open
title: Ctypes._FuncPtr.restype doesn't handle NoneType correctly
type: behavior
versions: Python 3.10
Added file: 
https://bugs.python.org/file49803/minimal_example_ctypes_nonetype_behaviour.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43208>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to