From 763b52fd10303990a3a69cd4b65d5dce1258cc5b Mon Sep 17 00:00:00 2001 From: Alex Lin Date: Tue, 31 Oct 2023 10:13:27 -0500 Subject: [PATCH] AttributeError not being raised in SWIG 4 when making an improper assignment in input processor #1288 (#1603) In convert_swig added a line to override the __setattr__ function. This makes the new SWIG behave like older SWIG versions. the _swig_setattr_nondynamic_instance_variable function is provided by SWIG and is similar to what our version of _swig_setattr_nondynamic above is. If later we need to override _swig_setattr_nondynamic_instance_variable it can be done the same way as before. --- libexec/trick/convert_swig | 1 + 1 file changed, 1 insertion(+) diff --git a/libexec/trick/convert_swig b/libexec/trick/convert_swig index 74595770..d208e3d4 100755 --- a/libexec/trick/convert_swig +++ b/libexec/trick/convert_swig @@ -669,6 +669,7 @@ sub process_class($$$$$) { push @$class_names_ref , "$curr_namespace$class_name" ; # write the class contents and semicolon to ensure any template declarations below are after the semicolon. + $$new_contents_ref .= "\n#if SWIG_VERSION > 0x040000\n\%pythoncode \%{\n __setattr__ = _swig_setattr_nondynamic_instance_variable(object.__setattr__)\n\%}\n#endif\n" ; $$new_contents_ref .= $extracted . ";\n" ; # write out the templated variable declaration lines found in this class. $$new_contents_ref .= $template_typedefs ;