code: def test_pass_by_value_finalizer(self):
      # bpo-37140: Similar to test_pass_by_value(), but the Python structure
      # has a finalizer (__del__() method): the finalizer must only be called
      # once.
  
      finalizer_calls = []
  
      class Test(Structure):
          _fields_ = [
              ("first", c_ulong),
              ("second", c_ulong),
              ("third", c_ulong),
          ]
  
          def __del__(self):
              finalizer_calls.append("called")
  
      s = Test(1, 2, 3)
      # Test the StructUnionType_paramfunc() code path which copies the
      # structure: if the structure is larger than sizeof(void*).
      self.assertGreater(sizeof(s), sizeof(c_void_p))
  
      dll = CDLL(_ctypes_test.__file__)
      func = dll._testfunc_large_struct_update_value
      func.argtypes = (Test,)
      func.restype = None
      func(s)
      # bpo-37140: Passing the structure by reference must not call
      # its finalizer!
      self.assertEqual(finalizer_calls, [])
      self.assertEqual(s.first, 1)
      self.assertEqual(s.second, 2)
      self.assertEqual(s.third, 3)
  
      # The finalizer must be called exactly once
      s = None
      support.gc_collect()
      self.assertEqual(finalizer_calls, ["called"])
  
imports: import _ctypes_test
  from platform import architecture
  import struct
  import sys
  import unittest
  from ctypes import CDLL, Array, Structure, Union, POINTER, sizeof, byref, alignment, c_void_p, c_char, c_wchar, c_byte, c_ubyte, c_uint8, c_uint16, c_uint32, c_short, c_ushort, c_int, c_uint, c_long, c_ulong, c_longlong, c_ulonglong, c_float, c_double
  from ctypes.util import find_library
  from struct import calcsize
  from collections import namedtuple
  from test import support
  from ._support import _CData, PyCStructType, Py_TPFLAGS_DISALLOW_INSTANTIATION, Py_TPFLAGS_IMMUTABLETYPE
label_desc: Use image node_id 25 for calling the StructureTestCase obj's underlying member method code with example usage: obj.test_pass_by_value_finalizer() without return types