File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -1208,7 +1208,7 @@ def _get_slots(cls):
1208
1208
slots = []
1209
1209
if getattr (cls , '__weakrefoffset__' , - 1 ) != 0 :
1210
1210
slots .append ('__weakref__' )
1211
- if getattr (cls , '__dictrefoffset__ ' , - 1 ) != 0 :
1211
+ if getattr (cls , '__dictoffset__ ' , - 1 ) != 0 :
1212
1212
slots .append ('__dict__' )
1213
1213
yield from slots
1214
1214
case str (slot ):
Original file line number Diff line number Diff line change @@ -3664,6 +3664,23 @@ class A(WithDictSlot): ...
3664
3664
self .assertEqual (A ().__dict__ , {})
3665
3665
A ()
3666
3666
3667
+ @support .cpython_only
3668
+ def test_dataclass_slot_dict_ctype (self ):
3669
+ # https://github.com/python/cpython/issues/123935
3670
+ from test .support import import_helper
3671
+ # Skips test if `_testcapi` is not present:
3672
+ _testcapi = import_helper .import_module ('_testcapi' )
3673
+
3674
+ @dataclass (slots = True )
3675
+ class A (_testcapi .HeapCTypeWithDict ):
3676
+ __dict__ : dict = {}
3677
+ self .assertEqual (A .__slots__ , ())
3678
+
3679
+ @dataclass (slots = True )
3680
+ class A (_testcapi .HeapCTypeWithWeakref ):
3681
+ __dict__ : dict = {}
3682
+ self .assertEqual (A .__slots__ , ('__dict__' ,))
3683
+
3667
3684
@support .cpython_only
3668
3685
def test_slots_with_wrong_init_subclass (self ):
3669
3686
# TODO: This test is for a kinda-buggy behavior.
You can’t perform that action at this time.
0 commit comments