New submission from Justin Capella <justincape...@gmail.com>:

When subclassing the ctypes.Structure class, __new__ and __init__ are not 
invoked when using the inherited classmethod from_buffer_copy to create the 
object.

I think this is because tp_alloc is ultimately used by GenericPyCData_new when 
creating the object using the from_buffer_copy classmethod inherited from 
_CData.

https://github.com/python/cpython/blob/be143ec99674ba38c5811f34cdb85ef39c2dc8f8/Modules/_ctypes/_ctypes.c#L3202

Expected behavior: creation of Structure subclass object would invoke __new__ 
and possibly __init__.

----------
components: ctypes
files: ctypesnew.py
messages: 357022
nosy: b1tninja
priority: normal
severity: normal
status: open
title: GenericPyCData_new does not invoke new or init
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9
Added file: https://bugs.python.org/file48723/ctypesnew.py

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

Reply via email to