New submission from Géry <gery.o...@gmail.com>:

When

```
TypeError: __weakref__ slot disallowed: either we already got one, or 
__itemsize__ != 0
```

is raised, the second condition `base->tp_itemsize != 0` (i.e. the base is a 
*variable-length* type, like `int`, `tuple` and `bytes`) in the error message 
is impossible since using a non-empty `__slots__` (e.g. `__slots__ = 
('__weakref__',)`) for a subtype of a variable-length type raises a

```
TypeError: nonempty __slots__ not supported for subtype of '…'
```

earlier in the `type.__new__` implementation.

----------
components: Interpreter Core
messages: 390851
nosy: maggyero
priority: normal
severity: normal
status: open
title: Fix the error message for disallowed __weakref__ slots
type: enhancement
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43814>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to