Merge branch 'ahnolds-py_gettar'
* ahnolds-py_gettar: update changes file for attribute fix Add python AttributeError test for non-existent attribute Fixing python attribute lookup Conflicts: CHANGES.current
This commit is contained in:
commit
a97441613e
3 changed files with 19 additions and 6 deletions
|
|
@ -5,6 +5,13 @@ See the RELEASENOTES file for a summary of changes in each release.
|
|||
Version 3.0.9 (in progress)
|
||||
===========================
|
||||
|
||||
2016-04-02: ahnolds
|
||||
[Python] Apply #598. Fix misleading error message when attempting to read a non-existent
|
||||
attribute. The previous cryptic error message:
|
||||
AttributeError: type object 'object' has no attribute '__getattr__'
|
||||
is now replaced with one mentioning the attribute name, eg:
|
||||
AttributeError: 'Foo' object has no attribute 'bar'
|
||||
|
||||
2016-04-02: derkuci
|
||||
[Python] Patch #610 to fix #607.
|
||||
Fix single arguments when using python -builtin -O with %feature("compactdefaultargs")
|
||||
|
|
|
|||
|
|
@ -71,3 +71,13 @@ if myStringyClass.ReadWriteString != "changed string":
|
|||
raise RuntimeError
|
||||
if myStringyClass.ReadOnlyString != "changed string":
|
||||
raise RuntimeError
|
||||
|
||||
# Check a proper AttributeError is raised for non-existent attributes, old versions used to raise unhelpful error:
|
||||
# AttributeError: type object 'object' has no attribute '__getattr__'
|
||||
try:
|
||||
x = myFoo.does_not_exist
|
||||
raise RuntimeError
|
||||
except AttributeError, e:
|
||||
if str(e).find("does_not_exist") == -1:
|
||||
raise RuntimeError
|
||||
|
||||
|
|
|
|||
|
|
@ -897,15 +897,11 @@ public:
|
|||
"\n", "def _swig_setattr(self, class_type, name, value):\n", tab4, "return _swig_setattr_nondynamic(self, class_type, name, value, 0)\n\n", NIL);
|
||||
|
||||
Printv(f_shadow,
|
||||
"\n", "def _swig_getattr_nondynamic(self, class_type, name, static=1):\n",
|
||||
"\n", "def _swig_getattr(self, class_type, name):\n",
|
||||
tab4, "if (name == \"thisown\"):\n", tab8, "return self.this.own()\n",
|
||||
tab4, "method = class_type.__swig_getmethods__.get(name, None)\n",
|
||||
tab4, "if method:\n", tab8, "return method(self)\n",
|
||||
tab4, "if (not static):\n",
|
||||
tab4, tab4, "return object.__getattr__(self, name)\n",
|
||||
tab4, "else:\n",
|
||||
tab4, tab4, "raise AttributeError(name)\n\n",
|
||||
"def _swig_getattr(self, class_type, name):\n", tab4, "return _swig_getattr_nondynamic(self, class_type, name, 0)\n\n", NIL);
|
||||
tab4, "raise AttributeError(\"'%s' object has no attribute '%s'\" % (class_type.__name__, name))\n\n", NIL);
|
||||
|
||||
Printv(f_shadow,
|
||||
"\n", "def _swig_repr(self):\n",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue