diff options
author | Victor Stinner <vstinner@python.org> | 2021-04-30 10:46:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-30 10:46:15 (GMT) |
commit | 3bb09947ec4837de75532e21dd4bd25db0a1f1b7 (patch) | |
tree | 46469716b18eda1c8af7c311b6187fda39a146c1 /Doc/whatsnew | |
parent | b73b5fb9ea08156991a065c1696e8d8cf7622482 (diff) | |
download | cpython-3bb09947ec4837de75532e21dd4bd25db0a1f1b7.zip cpython-3bb09947ec4837de75532e21dd4bd25db0a1f1b7.tar.gz cpython-3bb09947ec4837de75532e21dd4bd25db0a1f1b7.tar.bz2 |
bpo-43916: Add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag (GH-25721)
Add a new Py_TPFLAGS_DISALLOW_INSTANTIATION type flag to disallow
creating type instances: set tp_new to NULL and don't create the
"__new__" key in the type dictionary.
The flag is set automatically on static types if tp_base is NULL or
&PyBaseObject_Type and tp_new is NULL.
Use the flag on the following types:
* _curses.ncurses_version type
* _curses_panel.panel
* _tkinter.Tcl_Obj
* _tkinter.tkapp
* _tkinter.tktimertoken
* _xxsubinterpretersmodule.ChannelID
* sys.flags type
* sys.getwindowsversion() type
* sys.version_info type
Update MyStr example in the C API documentation to use
Py_TPFLAGS_DISALLOW_INSTANTIATION.
Add _PyStructSequence_InitType() function to create a structseq type
with the Py_TPFLAGS_DISALLOW_INSTANTIATION flag set.
type_new() calls _PyType_CheckConsistency() at exit.
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r-- | Doc/whatsnew/3.10.rst | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 2580a03..1a39066 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -1708,6 +1708,10 @@ New Features These functions allow to activate, deactivate and query the state of the garbage collector from C code without having to import the :mod:`gc` module. +* Add a new :c:data:`Py_TPFLAGS_DISALLOW_INSTANTIATION` type flag to disallow + creating type instances. + (Contributed by Victor Stinner in :issue:`43916`.) + Porting to Python 3.10 ---------------------- |