[issue26979] The danger of PyType_FromSpec()

2018-10-26 Thread Christian Tismer
Christian Tismer added the comment: The default of PyType_FromSpec for tp_dealloc is wrong! --- After a long struggle with crashes and leaks, the situation was finally clarified: When a type is converted from a static type to a heaptype via

[issue26979] The danger of PyType_FromSpec()

2018-09-17 Thread Christian Tismer
Christian Tismer added the comment: If somebody is interested to see how the transition to the Limited API was done, here is the documentation that I was forced to write :) https://github.com/pyside/pyside2-setup/blob/5.11/sources/shiboken2/libshiboken/pep384impl_doc.rst --

[issue26979] The danger of PyType_FromSpec()

2018-09-17 Thread Christian Tismer
Christian Tismer added the comment: > ... Specifically, you need a way to create class with a metaclass, from C. > > Is that right? Or was this only an example of a larger problem? Yes, you are exactly right. I needed access to very few fields. In particular: PyTypeObject.tp_init

[issue26979] The danger of PyType_FromSpec()

2018-09-17 Thread Petr Viktorin
Petr Viktorin added the comment: Ah! It seems you don't need access to all tp_* slots of any type here, but just to PyType.tp_new – only one specific type, and only one specific slot. Specifically, you need a way to create class with a metaclass, from C. Is that right? Or was this only an

[issue26979] The danger of PyType_FromSpec()

2018-09-16 Thread Neil Schemenauer
Change by Neil Schemenauer : -- nosy: +nascheme ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue26979] The danger of PyType_FromSpec()

2018-09-15 Thread Christian Tismer
Christian Tismer added the comment: > 1) If I understand correctly, this problem could be solved by > per-class C storage? Something like PyModuleDef.m_size / > PyModule_GetState, but for classes? No. To obtain sizeof(PyType_Type), we simply used the Python code type.__basicsize__ It is

[issue26979] The danger of PyType_FromSpec()

2018-09-14 Thread Petr Viktorin
Petr Viktorin added the comment: 1) If I understand correctly, this problem could be solved by per-class C storage? Something like PyModuleDef.m_size / PyModule_GetState, but for classes? 2) Making PyType_GetSlot work for static types would not be trivial. All types do have the same *basic*

[issue26979] The danger of PyType_FromSpec()

2018-09-13 Thread Christian Tismer
Christian Tismer added the comment: Petr, Fine! PySide's problems are solved for now, no worries. But as mentioned, there is more. Problem 1) -- There is another thing that gives problems: When creating types which have fields "behind" the normal type fields, PySide had explicit

[issue26979] The danger of PyType_FromSpec()

2018-09-13 Thread Petr Viktorin
Petr Viktorin added the comment: Thanks! I think that explains enough of the issue. Converting static types to heap ones is just one way you can use PyType_Spec. Another is writing new types, which should work much like Python classes. So I don't think we should change the default, but

[issue26979] The danger of PyType_FromSpec()

2018-09-12 Thread Christian Tismer
Christian Tismer added the comment: Hi Petr, yes I have that what generated the wrong thing, but it is inside a specific PySide repository in a big project. Before I try to extract and simulate that, let me just show it. All types which had been no heaptypes before were already quite

[issue26979] The danger of PyType_FromSpec()

2018-09-11 Thread Petr Viktorin
Petr Viktorin added the comment: Christian, do you have a specific example of the default tp_dealloc doing the wrong thing? -- ___ Python tracker ___

[issue26979] The danger of PyType_FromSpec()

2018-09-11 Thread Petr Viktorin
Petr Viktorin added the comment: I don't think PEP 384 should be updated. It documents the feature as it was added, and shouldn't be used as documentation now. Instead, Python documentation should be improved to cover all of PEP 389. I submitted a pull request for that (GH-9154). For this

[issue26979] The danger of PyType_FromSpec()

2018-06-02 Thread Christian Tismer
Christian Tismer added the comment: There is another catch that belongs in the same category. There is line 2841 in typeobject.c if (type->tp_dealloc == NULL) { /* It's a heap type, so needs the heap types' dealloc. subtype_dealloc will call the base type's tp_dealloc,

[issue26979] The danger of PyType_FromSpec()

2018-06-02 Thread Terry J. Reedy
Change by Terry J. Reedy : -- stage: -> needs patch versions: +Python 3.7, Python 3.8 -Python 3.5 ___ Python tracker ___ ___

[issue26979] The danger of PyType_FromSpec()

2018-04-09 Thread Nick Coghlan
Change by Nick Coghlan : -- nosy: +ncoghlan ___ Python tracker ___ ___ Python-bugs-list

[issue26979] The danger of PyType_FromSpec()

2018-04-09 Thread Petr Viktorin
Change by Petr Viktorin : -- nosy: +Dormouse759, encukou ___ Python tracker ___ ___

[issue26979] The danger of PyType_FromSpec()

2016-05-08 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: There is a catch when convert static types to dynamic types using PyType_FromSpec(). tp_new is not inherited for static types whose base class is 'object' (see a comment in inherit_special() in Objects/typeobject.c:4569 for explanation). Such types left