Skip to content
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 and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-43916: PyStdPrinter_Type uses Py_TPFLAGS_DISALLOW_INSTANTIATION #25749

Merged
merged 1 commit into from
Apr 30, 2021
Merged

bpo-43916: PyStdPrinter_Type uses Py_TPFLAGS_DISALLOW_INSTANTIATION #25749

merged 1 commit into from
Apr 30, 2021

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Apr 30, 2021

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.
@vstinner
Copy link
Member Author

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.

cc @erlend-aasland

@erlend-aasland
Copy link
Contributor

I'll have a look as soon as possible! Offline again :)

@vstinner vstinner merged commit 4908fae into python:master Apr 30, 2021
@vstinner vstinner deleted the stdprinter branch April 30, 2021 12:56
@vstinner
Copy link
Member Author

I merged my PR, but you can still review the merged change ;-)

@erlend-aasland
Copy link
Contributor

LGTM 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants