summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-07-21 02:29:46 (GMT)
committerGuido van Rossum <guido@python.org>1996-07-21 02:29:46 (GMT)
commit3cb486879a8ca504a61b747fae389bbc01756388 (patch)
tree1409ffc4414674825741104cdfc137158142201d
parent42cd305b252b176a51e1377bd08710726be2999b (diff)
downloadcpython-3cb486879a8ca504a61b747fae389bbc01756388.zip
cpython-3cb486879a8ca504a61b747fae389bbc01756388.tar.gz
cpython-3cb486879a8ca504a61b747fae389bbc01756388.tar.bz2
Only __dict__ and __class__ are read-only instance attributes
-rw-r--r--Objects/classobject.c6
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;