diff --git a/CHANGES.current b/CHANGES.current index 9591bb864..53ebf512b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,12 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.5 (in progress) =========================== +2015-01-30: wsfulton + [Python] 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. + 2015-01-27: smarchetto Support for the Scilab language has been added diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 7a2338f8f..c71a0f364 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -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);