[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2022-01-26 Thread STINNER Victor
STINNER Victor added the comment: In Python 3.11, 68 heap types have the Py_TPFLAGS_IMMUTABLETYPE flag: * _blake2.blake2b * _blake2.blake2s * _bz2.BZ2Compressor * _bz2.BZ2Decompressor * _csv.Dialect * _csv.reader * _csv.writer * _dbm.dbm * _gdbm.gdbm * _hashlib.HASH * _hashlib.HASHXOF *

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2022-01-26 Thread STINNER Victor
STINNER Victor added the comment: > Should the immutable flag also be applied to the heap types converted in and > before Python 3.9 before closing this issue? I don't think that Python 3.9 should be changed. It's too late. IMO this issue is not important enough to introduce a new type flag

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-07-09 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Yeah, I think these should be changed, but lest give a bit of time for other core devs to mention what they think -- ___ Python tracker

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-07-08 Thread Erlend E. Aasland
Erlend E. Aasland added the comment: These types now lack the Py_TPFLAGS_IMMUTABLETYPE flag: ## Types converted in Python 3.9 - _abc._abc_data - _json.Encoder - _json.Scanner - _random.Random - _struct.Struct - _struct.unpack_iterator - ast.AST - posix.DirEntry - posix.ScandirIterator -

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-07-08 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: I would say yes. Do you have a compiled list of what's left? -- ___ Python tracker ___

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-07-08 Thread Erlend E. Aasland
Erlend E. Aasland added the comment: > Is anything left here? Should the immutable flag also be applied to the heap types converted in and before Python 3.9 before closing this issue? -- ___ Python tracker

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-07-08 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- priority: release blocker -> ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-07-08 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Is anything left here? -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-07-08 Thread STINNER Victor
STINNER Victor added the comment: New changeset a3739b207adb5d17e3b53347df05b54b1a8b87f0 by Erlend Egeberg Aasland in branch 'main': bpo-43908: Immutable types inherit vectorcall (GH-27001) https://github.com/python/cpython/commit/a3739b207adb5d17e3b53347df05b54b1a8b87f0 --

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-07-02 Thread Erlend E. Aasland
Change by Erlend E. Aasland : -- pull_requests: +25562 pull_request: https://github.com/python/cpython/pull/27001 ___ Python tracker ___

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-07-01 Thread Guido van Rossum
Guido van Rossum added the comment: +1-- --Guido (mobile) -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-07-01 Thread Erlend E. Aasland
Erlend E. Aasland added the comment: In inherit_slots() in Objects/typeobject.c, Py_TPFLAGS_HAVE_VECTORCALL inheritance depends on if the base type is a heap type or not. This aligns with PEP 590[1]: Heap types never inherit the vectorcall protocol because that would not be safe (heap

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-06-17 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 7297d74251de3b1c02dcdb9ca281461cc7fb4535 by Miss Islington (bot) in branch '3.10': bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351) (GH-26766)

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-06-17 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 00710e6346fd2394aa020b2dfae170093effac98 by Erlend Egeberg Aasland in branch 'main': bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351)

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-06-17 Thread miss-islington
Change by miss-islington : -- pull_requests: +25352 pull_request: https://github.com/python/cpython/pull/26766 ___ Python tracker ___

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-06-05 Thread Erlend E. Aasland
Erlend E. Aasland added the comment: PR 26351 adds the Py_TPFLAGS_IMMUTABLETYPE type flag to all types converted to heap type during 3.10 development. -- ___ Python tracker

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-06-04 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- priority: deferred blocker -> release blocker ___ Python tracker ___ ___ Python-bugs-list

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-05-25 Thread Erlend E. Aasland
Change by Erlend E. Aasland : -- pull_requests: +24941 pull_request: https://github.com/python/cpython/pull/26351 ___ Python tracker ___

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-05-25 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Notice this issue is marked as "deferred blocker" it won't block this beta release (beta 2) but it will block the next. -- ___ Python tracker

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-05-25 Thread STINNER Victor
STINNER Victor added the comment: Guido: "I don’t think we’re waiting for more crazy hacks." Right now, _ast.AST is still mutable: $ ./python Python 3.11.0a0 (heads/subtype_dealloc-dirty:efd45ad788, May 21 2021 >>> import _ast >>> _ast.AST.x=1 >>> _ast.AST.x 1 --

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-05-25 Thread STINNER Victor
STINNER Victor added the comment: main branch: commit a09fc9c63f1b5980c62ff2712f67500bacb92b04 Author: Erlend Egeberg Aasland Date: Fri May 14 00:44:55 2021 +0200 bpo-43908: Add What's New entry for Py_TPFLAGS_IMMUTABLETYPE flag (GH-25816) --

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-05-13 Thread miss-islington
miss-islington added the comment: New changeset 3222b25b2f55d3b3d1dab4547bf7b5adaa1d874f by Miss Islington (bot) in branch '3.10': [3.10] bpo-43908: Add What's New entry for Py_TPFLAGS_IMMUTABLETYPE flag (GH-25816) (GH-26115)

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-05-13 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 11.0 -> 12.0 pull_requests: +24760 pull_request: https://github.com/python/cpython/pull/26115 ___ Python tracker

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-05-02 Thread Erlend Egeberg Aasland
Change by Erlend Egeberg Aasland : -- pull_requests: +24502 pull_request: https://github.com/python/cpython/pull/25816 ___ Python tracker ___

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-05-02 Thread Erlend Egeberg Aasland
Erlend Egeberg Aasland added the comment: Victor: > And in the "Porting to Python 3.10", I don't know if we should suggest > reviewing metatypes implemented in C which overrides tp_setattro, to take the > new flag in account. I don't know either; perhaps someone else could chime in here.

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-05-02 Thread Shreyan Avigyan
Shreyan Avigyan added the comment: Should I apply the flags on other newly converted heap types? -- ___ Python tracker ___ ___

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-05-02 Thread Christian Heimes
Christian Heimes added the comment: New changeset 91554e4c5ca3c762998296522f854a7166ba84f0 by Christian Heimes in branch 'master': bpo-43908: Mark ssl, hash, and hmac types as immutable (GH-25792) https://github.com/python/cpython/commit/91554e4c5ca3c762998296522f854a7166ba84f0 --

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-05-01 Thread Christian Heimes
Christian Heimes added the comment: What's the plan for heap type exceptions? PyErr_NewException() and PyErr_NewExceptionWithDoc() doesn't accept flags. -- ___ Python tracker

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-05-01 Thread Christian Heimes
Change by Christian Heimes : -- pull_requests: +24482 pull_request: https://github.com/python/cpython/pull/25792 ___ Python tracker ___

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: I am decreasing the priority of this to deferred blocker since https://bugs.python.org/issue43916 is mostly fixed -- priority: release blocker -> deferred blocker ___ Python tracker

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Shreyan Avigyan
Shreyan Avigyan added the comment: Ok -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Shreyan Avigyan
Shreyan Avigyan added the comment: Ok -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor
STINNER Victor added the comment: > Victor, the types, that Py_TPFLAGS_IMMUTABLETYPE flag is yet to be applied > to, are different for 3.9 and 3.10. Should we proceed with that? (If yes I'd > be happy to collaborate with Erlend to apply the flag on those types.) Please don't change the

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Shreyan Avigyan
Shreyan Avigyan added the comment: Victor, the types, that Py_TPFLAGS_IMMUTABLETYPE flag is yet to be applied to, are different for 3.9 and 3.10. Should we proceed with that? (If yes I'd be happy to collaborate with Erlend to apply the flag on those types.) --

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor
STINNER Victor added the comment: Moreover, all static types get the Py_TPFLAGS_IMMUTABLETYPE flag automatically. For example, "./python -c pass" initializes 196 immutable static types: * ArithmeticError * AssertionError * AttributeError * BaseException * BlockingIOError * BrokenPipeError *

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor
STINNER Victor added the comment: Currently, 4 types are declared with Py_TPFLAGS_IMMUTABLETYPE explicitly: * array.array * re.Pattern * re.Match * _sre.SRE_Scanner -- ___ Python tracker

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor
STINNER Victor added the comment: New changeset 64141382ecbad665d5738ff26d15505f3427c724 by Erlend Egeberg Aasland in branch 'master': bpo-43908: check_set_special_type_attr() checks Py_TPFLAGS_IMMUTABLETYPE (GH-25743)

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Erlend Egeberg Aasland
Erlend Egeberg Aasland added the comment: Yes, I’ll have a look at it this afternoon. (On mobile now.) -- ___ Python tracker ___

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor
STINNER Victor added the comment: Erlend: would you mind to document the new Py_TPFLAGS_IMMUTABLETYPE flag in the C API section of What's New in Python 3.10? https://docs.python.org/dev/whatsnew/3.10.html#c-api-changes In "New Features", something like: * Add a new

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor
STINNER Victor added the comment: https://docs.python.org/dev/c-api/typeobj.html#Py_TPFLAGS_IMMUTABLETYPE says: "This bit is set for type objects that are immutable: type attributes cannot be set nor deleted." Is it possible that a metatype (type subtype) overrides tp_setattro and ignores

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor
STINNER Victor added the comment: PyStdPrinter_Type implements tp_new, but tp_init always fail: static int stdprinter_init(PyObject *self, PyObject *args, PyObject *kwds) { PyErr_SetString(PyExc_TypeError, "cannot create 'stderrprinter' instances"); return -1; }

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor
STINNER Victor added the comment: See also bpo-24912 "The type of cached objects is mutable". -- ___ Python tracker ___ ___

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Erlend Egeberg Aasland
Erlend Egeberg Aasland added the comment: Included in GH-25743 -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Erlend Egeberg Aasland
Erlend Egeberg Aasland added the comment: I just found it myself :) pushing out the PR now! -- ___ Python tracker ___ ___

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor
STINNER Victor added the comment: Hum, another function should be updated. Do you want to propose a fix Erlend? static int type_set_annotations(PyTypeObject *type, PyObject *value, void *context) { if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) { PyErr_Format(PyExc_TypeError, "can't

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Erlend Egeberg Aasland
Change by Erlend Egeberg Aasland : -- pull_requests: +24433 pull_request: https://github.com/python/cpython/pull/25743 ___ Python tracker ___

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Erlend Egeberg Aasland
Erlend Egeberg Aasland added the comment: Yep, I agree. From my coverage output, it seems that this branch is never executed. BUT, that may of course be because there's no test that exercises this branch. -- ___ Python tracker

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor
STINNER Victor added the comment: > Is this always the case? If so, can we turn the check in > check_set_special_type_attr() into an assert? In any case, > Py_TPFLAGS_IMMUTABLETYPE should be used, not !Py_TPFLAGS_HEAPTYPE. I don't know. In case of doubt, I suggest to only replace

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Erlend Egeberg Aasland
Erlend Egeberg Aasland added the comment: Victor: > check_set_special_type_attr() is used to prevent setting the following > attributes: > [...] > Right now, I cannot set the attribues on array.array type: > [...] > I guess that type_setattro() is used and it checks for >

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Shreyan Avigyan
Shreyan Avigyan added the comment: Py_TPFLAGS_IMMUTABLETYPE has been applied to array.array by Erlend in https://github.com/python/cpython/pull/25696. Should Py_TPFLAGS_IMMUTABLETYPE be applied to other heap types also (the ones that were converted from static types)? --

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-29 Thread Guido van Rossum
Guido van Rossum added the comment: I don’t think we’re waiting for more crazy hacks. On Thu, Apr 29, 2021 at 07:27 STINNER Victor wrote: > > STINNER Victor added the comment: > > > > https://discuss.python.org/t/list-of-built-in-types-converted-to-heap-types/8403 > > In the past, I used

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-29 Thread STINNER Victor
STINNER Victor added the comment: > https://discuss.python.org/t/list-of-built-in-types-converted-to-heap-types/8403 In the past, I used _random.Random for manual tests to compare static type and heap types, check which one is mutable. C type _random.Random is inherited by Python type

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-29 Thread Erlend Egeberg Aasland
Erlend Egeberg Aasland added the comment: > check_set_special_type_attr() must also be updated to check for > Py_TPFLAGS_IMMUTABLETYPE flag. Ok, lets just use this issue for the PR. I can fix it in an hour or so. -- ___ Python tracker

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-29 Thread STINNER Victor
STINNER Victor added the comment: > Erlend: Do you want to write such change? Erlend created bpo-43973 and PR 25714. -- ___ Python tracker ___

[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-29 Thread STINNER Victor
Change by STINNER Victor : -- title: array.array should remain immutable -> array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag ___ Python tracker ___