Skip to content

Conversation

@vstinner
Copy link
Member

@vstinnervstinner 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
MemberAuthor

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 :)

@vstinnervstinner merged commit 4908fae into python:masterApr 30, 2021
@vstinnervstinner deleted the stdprinter branch April 30, 2021 12:56
@vstinner
Copy link
MemberAuthor

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

@erlend-aasland
Copy link
Contributor

LGTM 😀

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@vstinner@erlend-aasland@the-knights-who-say-ni@bedevere-bot