This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PyType_FromSpec can't create immutable types
Type: Stage:
Components: Interpreter Core Versions: Python 3.9, Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: dino.viehland, eric.snow, vstinner
Priority: normal Keywords:

Created on 2019-05-21 21:31 by dino.viehland, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg343100 - (view) Author: Dino Viehland (dino.viehland) * (Python committer) Date: 2019-05-21 21:31
This is another catch of using PyType_FromSpec (similar to  https://bugs.python.org/issue26979 but also completely different).

Because PyType_FromSpec produces a heap type it gets the Py_TPFLAGS_HEAPTYPE flag set on the newly produced type.  To enforce the immutability of built-in types type_setattro checks this flag.  Therefore these types end up being mutable, e.g:

import _ssl
_ssl.SSLError.x = 42

In addition to not providing parity for replacing PyType_Ready in the stable API, it also means that this could presumably bleed across sub-interpreters or just provide surprising and bad results.
History
Date User Action Args
2022-04-11 14:59:15adminsetgithub: 81183
2019-05-21 21:31:10dino.viehlandcreate