This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fix the error message for disallowed __weakref__ slots
Type: enhancement Stage: patch review
Components: Interpreter Core Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: maggyero
Priority: normal Keywords: patch

Created on 2021-04-12 13:55 by maggyero, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 25362 open maggyero, 2021-04-12 13:55
Messages (1)
msg390851 - (view) Author: Géry (maggyero) * Date: 2021-04-12 13:55
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.
History
Date User Action Args
2022-04-11 14:59:44adminsetgithub: 87980
2022-01-15 19:22:04iritkatrielsetversions: + Python 3.11, - Python 3.6, Python 3.7, Python 3.8, Python 3.9, Python 3.10
2021-04-12 13:55:39maggyerosetkeywords: + patch
stage: patch review
pull_requests: + pull_request24096
2021-04-12 13:55:17maggyerocreate