mirror of
https://github.com/python/cpython.git
synced 2025-07-30 14:44:10 +00:00
[3.13] gh-123935: Fix typo in _get_slots
in dataclasses.py
(GH-123941) (#123991)
gh-123935: Fix typo in `_get_slots` in `dataclasses.py` (GH-123941)
(cherry picked from commit ac918ccad7
)
Co-authored-by: sobolevn <mail@sobolevn.me>
This commit is contained in:
parent
a63e06d95b
commit
ae3f347dc0
3 changed files with 22 additions and 1 deletions
|
@ -3707,6 +3707,25 @@ class TestSlots(unittest.TestCase):
|
|||
self.assertEqual(A().__dict__, {})
|
||||
A()
|
||||
|
||||
@support.cpython_only
|
||||
def test_dataclass_slot_dict_ctype(self):
|
||||
# https://github.com/python/cpython/issues/123935
|
||||
from test.support import import_helper
|
||||
# Skips test if `_testcapi` is not present:
|
||||
_testcapi = import_helper.import_module('_testcapi')
|
||||
|
||||
@dataclass(slots=True)
|
||||
class HasDictOffset(_testcapi.HeapCTypeWithDict):
|
||||
__dict__: dict = {}
|
||||
self.assertNotEqual(_testcapi.HeapCTypeWithDict.__dictoffset__, 0)
|
||||
self.assertEqual(HasDictOffset.__slots__, ())
|
||||
|
||||
@dataclass(slots=True)
|
||||
class DoesNotHaveDictOffset(_testcapi.HeapCTypeWithWeakref):
|
||||
__dict__: dict = {}
|
||||
self.assertEqual(_testcapi.HeapCTypeWithWeakref.__dictoffset__, 0)
|
||||
self.assertEqual(DoesNotHaveDictOffset.__slots__, ('__dict__',))
|
||||
|
||||
@support.cpython_only
|
||||
def test_slots_with_wrong_init_subclass(self):
|
||||
# TODO: This test is for a kinda-buggy behavior.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue