Skip to content

Conversation

@thejcannon
Copy link
Contributor

@thejcannon thejcannon commented Feb 9, 2025

Fixes #129915 by shifting the "set the __qualname__" responsibility to be a property of the __qualname__ being inside the class namespace.

(For the record, oof the bug was really painful to run into 😅 )

@thejcannon thejcannon changed the title gh- 129915: Add __qualname__ to class namespace when constructing slotted dataclass gh-129915: Add __qualname__ to class namespace when constructing slotted dataclass Feb 9, 2025
Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, also add a NEWS entry.

class D(C):
pass

self.assertEqual(D.__qualname__, 'TestSlots.test_slots_qualname.<locals>.D')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please run your tests as -m test test_dataclasses and as python.exe Lib/test/test_dataclasses/__init__.py directly? qualname might be changed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I'm not following how running it directly would produce a different result than the passing CI check? What am I missing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume @sobolevn thinks the imported class name might change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I am not sure it will, just double checking.

@python-cla-bot
Copy link

The following commit authors need to sign the Contributor License Agreement:

CLA signed

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.

Incorrect __qualname__ in slotted dataclasses in __init_subclass__

3 participants