bpo-43916: PyStdPrinter_Type uses Py_TPFLAGS_DISALLOW_INSTANTIATION by vstinner · Pull Request #25749 · python/cpython (original) (raw)
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation4 Commits1 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
The PyStdPrinter_Type type now uses the
Py_TPFLAGS_DISALLOW_INSTANTIATION flag to disallow instantiation,
rather than seting a tp_init method which always fail.
Write also unit tests for PyStdPrinter_Type.
https://bugs.python.org/issue43916
The PyStdPrinter_Type type now uses the Py_TPFLAGS_DISALLOW_INSTANTIATION flag to disallow instantiation, rather than seting a tp_init method which always fail.
Write also unit tests for PyStdPrinter_Type.
The funny part is that technically, Py_TPFLAGS_DISALLOW_INSTANTIATION or setting tp_new explicitly to NULL are not needed.
Since it's a static type, tp_new is NULL and tp_base is NULL, it gets Py_TPFLAGS_DISALLOW_INSTANTIATION flag automatically.
I'll have a look as soon as possible! Offline again :)
I merged my PR, but you can still review the merged change ;-)