Fix Python -classic and property setting
Setting properties on classic classes was broken in swig-3.0.3 by attempting to use __setattr__. This regression is fixed now by using __dict__ again when using -classic. Fixes patch #232.
This commit is contained in:
parent
727d74f6be
commit
39a75442a1
2 changed files with 17 additions and 1 deletions
|
|
@ -873,7 +873,17 @@ public:
|
|||
#else
|
||||
tab4, "if (not static):\n",
|
||||
#endif
|
||||
tab4, tab4, "object.__setattr__(self, name, value)\n",
|
||||
NIL);
|
||||
if (!classic) {
|
||||
if (!modern)
|
||||
Printv(f_shadow, tab4, tab4, "if _newclass:\n", tab4, NIL);
|
||||
Printv(f_shadow, tab4, tab4, "object.__setattr__(self, name, value)\n", NIL);
|
||||
if (!modern)
|
||||
Printv(f_shadow, tab4, tab4, "else:\n", tab4, NIL);
|
||||
}
|
||||
if (classic || !modern)
|
||||
Printv(f_shadow, tab4, tab4, "self.__dict__[name] = value\n", NIL);
|
||||
Printv(f_shadow,
|
||||
tab4, "else:\n",
|
||||
tab4, tab4, "raise AttributeError(\"You cannot add attributes to %s\" % self)\n\n",
|
||||
"\n", "def _swig_setattr(self, class_type, name, value):\n", tab4, "return _swig_setattr_nondynamic(self, class_type, name, value, 0)\n\n", NIL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue