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:
William S Fulton 2015-01-30 22:24:46 +00:00
commit 39a75442a1
2 changed files with 17 additions and 1 deletions

View file

@ -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);