diff --git a/CHANGES.current b/CHANGES.current index e1dafdc34..8e388dee5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,15 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.0 (in progress) ============================ +2014-03-02: wsfulton + [Python] SF Patch #346 from Jens Krueger. Correct exception thrown attempting to + access a non-existent C/C++ global variable on the 'cvar' object. The exception thrown + used to be a NameError. However, as this access is via a primary, an AttributeError + is more correct and so the exception thrown now is an AttributeError. Reference: + http://docs.python.org/2/reference/expressions.html#attribute-references + + *** POTENTIAL INCOMPATIBILITY *** + 2014-03-01: wsfulton [Python] Patch #143 Fix type shown when using type() to include the module and package name when using -builtin. diff --git a/Examples/test-suite/global_vars.i b/Examples/test-suite/global_vars.i index 8c18bbd34..d562d1eaa 100644 --- a/Examples/test-suite/global_vars.i +++ b/Examples/test-suite/global_vars.i @@ -28,4 +28,9 @@ Hello h; Hello *hp; Hello &hr = h; + + void init() { + b = "string b"; + x = 1234; + } %} diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 585fcaa27..b44c2c893 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -116,7 +116,7 @@ swig_varlink_getattr(swig_varlinkobject *v, char *n) { var = var->next; } if (res == NULL && !PyErr_Occurred()) { - PyErr_SetString(PyExc_AttributeError,"Unknown C global variable"); + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); } return res; } @@ -133,7 +133,7 @@ swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { var = var->next; } if (res == 1 && !PyErr_Occurred()) { - PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); } return res; }