File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1486,6 +1486,26 @@ def make_pairs():
14861486 self .assertEqual (d .get (key3_3 ), 44 )
14871487 self .assertGreaterEqual (eq_count , 1 )
14881488
1489+ def test_overwrite_managed_dict (self ):
1490+ # GH-130327: Overwriting an object's managed dict incorrectly stored
1491+ # the new dictionary in the managed dict pointer for objects supporting
1492+ # inline values, leading to early clearing of the dictionary
1493+ import gc
1494+
1495+ class Shenanigans :
1496+ pass
1497+
1498+ to_be_deleted = Shenanigans ()
1499+ to_be_deleted .attr = "whatever"
1500+ holds_reference = Shenanigans ()
1501+ holds_reference .__dict__ = to_be_deleted .__dict__
1502+ holds_reference .ref = {"circular" : to_be_deleted , "data" : 42 }
1503+
1504+ del to_be_deleted
1505+ gc .collect ()
1506+ self .assertEqual (holds_reference .ref ['data' ], 42 )
1507+ self .assertEqual (holds_reference .attr , "whatever" )
1508+
14891509
14901510class CAPITest (unittest .TestCase ):
14911511
You can’t perform that action at this time.
0 commit comments