youknowone · GitHub

Bug report

Bug description:

# Add a code block here, if required
    def test_set_type_updates_format(self):
        # to match the element type's format
        with self.assertWarns(DeprecationWarning):
            lp = POINTER("node")
        class node(Structure):
            _fields_ = [("value", c_int)]
        # Get the expected format before set_type
        node_format = memoryview(node()).format
        expected_format = "&" + node_format
        lp.set_type(node)
        # Create instance to check format via memoryview
        n = node(42)
        p = lp(n)
        actual_format = memoryview(p).format
        # After set_type, the pointer's format should be "&<element_format>"
        self.assertEqual(actual_format, expected_format)

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

Read the original on github.com ↗