11/***********************************************************
2- Copyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
2+ Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The
33Netherlands.
44
55 All Rights Reserved
@@ -106,7 +106,7 @@ class_getattr(op, name)
106106 int i ;
107107 for (i = 0 ; i < n ; i ++ ) {
108108 v = class_getattr ((classobject * )
109- gettupleitem (op -> cl_bases , i ), name );
109+ gettupleitem (op -> cl_bases , i ), name );
110110 if (v != NULL )
111111 return v ;
112112 err_clear ();
@@ -122,6 +122,13 @@ class_setattr(op, name, v)
122122 char * name ;
123123 object * v ;
124124{
125+ if (name [0 ] == '_' && name [1 ] == '_' ) {
126+ int n = strlen (name );
127+ if (name [n - 1 ] == '_' && name [n - 2 ] == '_' ) {
128+ err_setstr (TypeError , "read-only special attribute" );
129+ return -1 ;
130+ }
131+ }
125132 if (v == NULL )
126133 return dictremove (op -> cl_methods , name );
127134 else
@@ -226,6 +233,13 @@ instance_setattr(inst, name, v)
226233 char * name ;
227234 object * v ;
228235{
236+ if (name [0 ] == '_' && name [1 ] == '_' ) {
237+ int n = strlen (name );
238+ if (name [n - 1 ] == '_' && name [n - 2 ] == '_' ) {
239+ err_setstr (TypeError , "read-only special attribute" );
240+ return -1 ;
241+ }
242+ }
229243 if (v == NULL )
230244 return dictremove (inst -> in_attr , name );
231245 else
0 commit comments