Author haberman2
Recipients Alexander.Belopolsky, Arfrever, Christian.Tismer, Robin.Schreiber, amaury.forgeotdarc, belopolsky, haberman2, jcea, jhaberman, lekma, loewis, mattip, petr.viktorin, pitrou, seberg, steve.dower
Date 2021-09-28.19:11:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> Everything is copied by `_FromSpec` after all.

One thing I noticed isn't copied is the string pointed to by tp_name:

This isn't an issue if tp_name is initialized from a string literal.  But if tp_name is created dynamically, it could lead to a dangling pointer.  If the general message is that "everything is copied by _FromSpec", it might make sense to copy the tp_name string too.

> However, I suppose that would replace a safe-by-design API with a "best practice" to never define the spec/slots statically (a best practice that is probably not generally followed or even advertised currently, I guess).

Yes that seems reasonable.  I generally prefer static declarations, since they will end up in .data instead of .text and will avoid a copy to the stack at runtime.  But these are very minor differences, especially for code that only runs once at startup, and a safe-by-default recommendation of always initializing PyType_* on the stack makes sense.
Date User Action Args
2021-09-28 19:11:53haberman2setrecipients: + haberman2, loewis, jcea, amaury.forgeotdarc, belopolsky, pitrou, Arfrever, petr.viktorin, lekma, Alexander.Belopolsky, mattip, Robin.Schreiber, steve.dower, seberg, Christian.Tismer, jhaberman
2021-09-28 19:11:53haberman2setmessageid: <>
2021-09-28 19:11:53haberman2linkissue15870 messages
2021-09-28 19:11:53haberman2create