Skip to content

Commit

Permalink
Add the call for __setattr__ for class templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
hchen99 committed Jul 9, 2024
1 parent bf0154c commit 0e9fce6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libexec/trick/convert_swig
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ sub process_template($$) {
my ( $contents_ref , $new_contents_ref ) = @_ ;
my $extracted ;

# Add _swig_setattr_nondynamic_instance_variable function for raising AttributeError for improper class attribute assingment in input processor
# The function call is inserted after the 1st { of the class template so it is placed at the top
$$contents_ref=~s/{\n/{\n\n#if SWIG_VERSION > 0x040000\n\%pythoncode \%{\n __setattr__ = _swig_setattr_nondynamic_instance_variable(object.__setattr__)\n\%}\n#endif\n/m;
if ( $$contents_ref =~ s/^(\s*;)//s ) {
$$new_contents_ref .= $1 ;
} else {
Expand Down

0 comments on commit 0e9fce6

Please sign in to comment.