diff options
author | Guido van Rossum <guido@python.org> | 1996-07-21 02:29:46 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-07-21 02:29:46 (GMT) |
commit | 3cb486879a8ca504a61b747fae389bbc01756388 (patch) | |
tree | 1409ffc4414674825741104cdfc137158142201d /Objects | |
parent | 42cd305b252b176a51e1377bd08710726be2999b (diff) | |
download | cpython-3cb486879a8ca504a61b747fae389bbc01756388.zip cpython-3cb486879a8ca504a61b747fae389bbc01756388.tar.gz cpython-3cb486879a8ca504a61b747fae389bbc01756388.tar.bz2 |
Only __dict__ and __class__ are read-only instance attributes
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/classobject.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c index f5a0d2a..27f1f26 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -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; |