Skip to content

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