summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorJurica Bradarić <jbradaric@users.noreply.github.com>2023-05-02 11:38:46 (GMT)
committerGitHub <noreply@github.com>2023-05-02 11:38:46 (GMT)
commit87223f32aba872cfebde6fbe38673799eb79f248 (patch)
treec75eeb511663531c2a822e3814877c1bd4fc62c4 /Lib
parentf6314b92dcfc8ca6ff3fd150814f85448db69165 (diff)
downloadcpython-87223f32aba872cfebde6fbe38673799eb79f248.zip
cpython-87223f32aba872cfebde6fbe38673799eb79f248.tar.gz
cpython-87223f32aba872cfebde6fbe38673799eb79f248.tar.bz2
gh-103743: Add PyUnstable_Object_GC_NewWithExtraData (GH-103744)
Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_capi/test_misc.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_capi/test_misc.py b/Lib/test/test_capi/test_misc.py
index 9470cf1..9d5d1ca 100644
--- a/Lib/test/test_capi/test_misc.py
+++ b/Lib/test/test_capi/test_misc.py
@@ -1043,6 +1043,20 @@ class CAPITest(unittest.TestCase):
self.assertEqual(_testcapi.function_get_kw_defaults(some), None)
self.assertEqual(some.__kwdefaults__, None)
+ def test_unstable_gc_new_with_extra_data(self):
+ class Data(_testcapi.ObjExtraData):
+ __slots__ = ('x', 'y')
+
+ d = Data()
+ d.x = 10
+ d.y = 20
+ d.extra = 30
+ self.assertEqual(d.x, 10)
+ self.assertEqual(d.y, 20)
+ self.assertEqual(d.extra, 30)
+ del d.extra
+ self.assertIsNone(d.extra)
+
class TestPendingCalls(unittest.TestCase):