From 1addb8cb0a98baf4a875b83020bc6edea3fff8bf Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Wed, 15 Mar 2023 23:48:57 -0400 Subject: [PATCH] Move to Py_SET_TYPE from Assigning to Py_TYPE result Python developers have been trying to move away from assigning directly to the result of a call to Py_TYPE to using Py_SET_TYPE to accomplish the same results. The latter is now required, not just preferred. --- pybindgen/cppclass.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pybindgen/cppclass.py b/pybindgen/cppclass.py index 9364adc..bd385c4 100644 --- a/pybindgen/cppclass.py +++ b/pybindgen/cppclass.py @@ -1988,7 +1988,7 @@ def generate(self, code_sink, module): % (self.pytypestruct, basenum, base.pytypestruct)) if metaclass is not None: - module.after_init.write_code('Py_TYPE(&%s) = &%s;' % + module.after_init.write_code('Py_SET_TYPE(&%s, &%s);' % (self.pytypestruct, metaclass.pytypestruct)) module.after_init.write_error_check('PyType_Ready(&%s)'