New submission from Dino Viehland <dinoviehl...@gmail.com>:

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.

----------
components: Interpreter Core
messages: 343100
nosy: dino.viehland, eric.snow, vstinner
priority: normal
severity: normal
status: open
title: PyType_FromSpec can't create immutable types
versions: Python 3.8, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37002>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to