[issue43908] array.array and re types must be immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-29 Thread Guido van Rossum


Guido van Rossum  added the comment:

That is as intended, right?

On Thu, Apr 29, 2021 at 07:59 STINNER Victor  wrote:

>
> STINNER Victor  added the comment:
>
> 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.
>
> --
>
> ___
> Python tracker 
> 
> ___
>
-- 
--Guido (mobile)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43908] array.array and re types must be immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-29 Thread STINNER Victor


STINNER Victor  added the comment:

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.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43908] array.array and re types must be immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-29 Thread STINNER Victor


Change by STINNER Victor :


--
title: array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag 
-> array.array and re types must be immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com