Message 392318 - Python tracker (original) (raw)
check_set_special_type_attr() is used to prevent setting the following attributes:
- name
- qualname
- module
- bases
- doc
Right now, I cannot set the attribues on array.array type:
$ ./python Python 3.10.0a7+ (heads/debug_doc2-dirty:0623fdb60d, Apr 29 2021, 12:06:18)
import array
array.array.name = 'newname' TypeError: can't set attributes of built-in/extension type 'array.array'
array.array.qualname = 'newname' TypeError: can't set attributes of built-in/extension type 'array.array'
array.array.module = 'new module' TypeError: can't set attributes of built-in/extension type 'array.array'
array.array.bases = (int,) TypeError: can't set attributes of built-in/extension type 'array.array'
array.array.doc = 'doc' TypeError: can't set attributes of built-in/extension type 'array.array'
I guess that type_setattro() is used and it checks for Py_TPFLAGS_IMMUTABLETYPE flag early.