Message392318
| Author |
vstinner |
| Recipients |
Guido.van.Rossum, Mark.Shannon, christian.heimes, corona10, erlendaasland, gvanrossum, pablogsal, serhiy.storchaka, shihai1991, shreyanavigyan, vstinner |
| Date |
2021年04月29日.14:59:29 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1619708369.98.0.0331315724797.issue43908@roundup.psfhosted.org> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2021年04月29日 14:59:30 | vstinner | set | recipients:
+ vstinner, gvanrossum, christian.heimes, Mark.Shannon, serhiy.storchaka, Guido.van.Rossum, corona10, pablogsal, shihai1991, erlendaasland, shreyanavigyan |
| 2021年04月29日 14:59:29 | vstinner | set | messageid: <1619708369.98.0.0331315724797.issue43908@roundup.psfhosted.org> |
| 2021年04月29日 14:59:29 | vstinner | link | issue43908 messages |
| 2021年04月29日 14:59:29 | vstinner | create |
|