bpo-43916: Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to selected types by erlend-aasland · Pull Request #25748 · python/cpython (original) (raw)

Does it really have anything to say? We hit the right exception anyway, AFAICS.

$ ./python.exe 
Python 3.10.0a7+ (heads/add-disallow-instantiation-flag:71439d0de8, Apr 30 2021, 15:22:20) [Clang 12.0.5 (clang-1205.0.22.9)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import array
>>> tp = type(iter(array.array('I')))
>>> tp()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot create 'array.arrayiterator' instances
>>> tp([])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot create 'array.arrayiterator' instances