Skip to content

gh-87980: Fix the error message for disallowed __weakref__ slots #25362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 1, 2023

Conversation

geryogam
Copy link
Contributor

@geryogam geryogam commented Apr 12, 2021

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.

When “TypeError: __weakref__ slot disallowed: either we already got one, or __itemsize__ != 0” is raised, the condition base->tp_itemsize != 0 is impossible since using a non-empty __slots__ for a subtype of a variable-length type raises a “TypeError: nonempty __slots__ not supported for subtype of '…'” earlier.
@github-actions
Copy link

github-actions bot commented Jun 3, 2021

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Jun 3, 2021
@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Aug 6, 2022
@geryogam geryogam changed the title bpo-43814: Fix the error message for disallowed __weakref__ slots gh-87980: Fix the error message for disallowed __weakref__ slots Dec 5, 2022
@geryogam
Copy link
Contributor Author

Thanks for the review.

@geryogam geryogam deleted the patch-23 branch February 11, 2023 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants