Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address review
  • Loading branch information
sobolevn committed Mar 12, 2024
commit 6dae168eaadec88a7360187f2797a8872831f482
1 change: 1 addition & 0 deletions Lib/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,7 @@ def _add_slots(cls, is_frozen, weakref_slot):
# as `method.__closure__`. Since we replace the class with a
# clone, we rewrite these references so it keeps working.
for item in cls.__dict__.values():
Comment thread
sobolevn marked this conversation as resolved.
item = inspect.unwrap(item)
if isinstance(item, (classmethod, staticmethod)):
closure_cells = getattr(item.__func__, "__closure__", None)
Comment on lines +1238 to +1239
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

classmethod and staticmethod have the __wrapped__ attribute since 3.10, so this code is perhaps dead.

elif isinstance(item, property):
Expand Down
22 changes: 22 additions & 0 deletions Lib/test/test_dataclasses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3628,6 +3628,28 @@ def cached_cl3(cls):
self.assertEqual(inst.cached_cl2(), 53)
self.assertEqual(inst.cached_cl3(), 64)

def test_super_without_params_single_wrapper(self):
def decorator(func):
@wraps(func)
def inner(*args, **kwargs):
return func(*args, **kwargs)
return inner

for slots in (True, False):
with self.subTest(slots=slots):
@dataclass(slots=True)
class A:
def method(self):
return 1

@dataclass(slots=True)
class B(A):
@decorator
def method(self):
return super().method()

self.assertEqual(B().method(), 1)


class TestDescriptors(unittest.TestCase):
def test_set_name(self):
Expand Down