Only __dict__ and __class__ are read-only instance attributes

This commit is contained in:
Guido van Rossum 1996-07-21 02:29:46 +00:00
parent 42cd305b25
commit 3cb486879a
1 changed files with 4 additions and 2 deletions

View File

@ -494,8 +494,10 @@ instance_setattr(inst, name, v)
object *v;
{
object *func, *args, *res;
if (name[0] == '_' && name[1] == '_') {
int n = strlen(name);
if (name[0] == '_' && name[1] == '_'
&& (strcmp(name, "__dict__") == 0 ||
strcmp(name, "__class__") == 0)) {
int n = strlen(name);
if (name[n-1] == '_' && name[n-2] == '_') {
err_setstr(TypeError, "read-only special attribute");
return -1;