diff --git a/TODO.txt b/TODO.txt index 1aa36fab..401dff10 100644 --- a/TODO.txt +++ b/TODO.txt @@ -89,29 +89,6 @@ possibilities to be considered. -PyAssertionError ----------------- - This is currently done by implementing wxPyApp::OnAssertionFailure - (mostly copied from Classic) where it will raise a wx.PyAssertionError if - the mode is set to wx.APP_ASSERT_EXCEPTION. There are still some - questions though... - - * Currently OnAssertionFailure cannot be overridden from Python code. - Should it be possible? - - * The /RaisesPyException/ annotation is now added to all - functions/methods generated from sip_generator. This is needed so code - will be generated that checks for a Python exception upon return from any - wrapped method. Unfortunately this means that any hand-written sip code - will not automatically get this annotation. I've asked Phil if there - could be a way for sip to turn on this mode for everything. No response - yet. - - * It would probably be good to have a way to turn off /RaisesPyException/ - for all methods in a class or whatever, for things where an assertion - exception is not expected, so they can be more efficient. Such as - wxPoint, wxSize, etc. - diff --git a/docs/MigrationGuide.txt b/docs/MigrationGuide.txt index b6d158ba..5361be1a 100644 --- a/docs/MigrationGuide.txt +++ b/docs/MigrationGuide.txt @@ -176,8 +176,8 @@ that is using the old names to use the new ones instead:: -wx.PyDeadObjectError ---------------------- +wx.PyDeadObjectError --> RuntimeError +------------------------------------- Classic wxPython tracks when the C++ part of some types of objects (pretty much just window types) is destroyed and then replaces the proxy object's @@ -191,4 +191,15 @@ conditional statement to see if it is safe to use, like this:: if someWindow: doSomething() - \ No newline at end of file + + +wx.PyAssertionError --> wx.wxAssertionError +------------------------------------------- + +This is the exception raised when one of the wxASSERT (or similar) statements +in the wx C++ code fails. Since it is a wxWidgets assertion and not a +wxPython assertion the name was changed to make that a little more clear. A +compatibility alias exists so using wx.PyAssertionError will still work, but +you should migrate those uses to wx.wxAssertionError if possible. + + diff --git a/etg/app.py b/etg/app.py index 433186f9..8d4e7316 100644 --- a/etg/app.py +++ b/etg/app.py @@ -138,7 +138,7 @@ def run(): wx.APP_ASSERT_DIALOG wx.APP_ASSERT_LOG - The default behavior is to raise a wx.PyAssertionError exception. + The default behavior is to raise a wx.wxAssertionError exception. """) m.addItem(etgtools.ParamDef(type='wxAppAssertMode', name='wxAppAssertMode')) c.addItem(m) diff --git a/src/app_ex.cpp b/src/app_ex.cpp index ff1bba79..f5f38b5a 100644 --- a/src/app_ex.cpp +++ b/src/app_ex.cpp @@ -184,7 +184,7 @@ private: IMPLEMENT_ABSTRACT_CLASS(wxPyApp, wxApp); wxPyApp* wxPyApp::ms_appInstance = NULL; -extern PyObject* wxPyAssertionError; +extern PyObject* wxAssertionError; // Exception object raised for wxASSERT failures void wxPyApp::OnAssertFailure(const wxChar *file, @@ -210,7 +210,7 @@ void wxPyApp::OnAssertFailure(const wxChar *file, // set the exception wxPyBlock_t blocked = wxPyBeginBlockThreads(); PyObject* s = wx2PyString(buf); - PyErr_SetObject(wxPyAssertionError, s); + PyErr_SetObject(wxAssertionError, s); Py_DECREF(s); wxPyEndBlockThreads(blocked); diff --git a/src/core_ex.cpp b/src/core_ex.cpp index 0c219b4b..78c4f2c1 100644 --- a/src/core_ex.cpp +++ b/src/core_ex.cpp @@ -33,14 +33,14 @@ void wxPyPreInit(PyObject* moduleDict) -PyObject* wxPyAssertionError = NULL; +PyObject* wxAssertionError = NULL; // Exception object raised for wxASSERT failures void wxPyCoreModuleInject(PyObject* moduleDict) { // Create an exception object to use for wxASSERTions - wxPyAssertionError = PyErr_NewException("wx._core.PyAssertionError", + wxAssertionError = PyErr_NewException("wx._core.wxAssertionError", PyExc_AssertionError, NULL); - PyDict_SetItemString(moduleDict, "PyAssertionError", wxPyAssertionError); + PyDict_SetItemString(moduleDict, "wxAssertionError", wxAssertionError); // // Create an exception object to use when the app object hasn't been created yet // wxPyNoAppError = PyErr_NewException("wx._core.PyNoAppError", diff --git a/src/core_ex.py b/src/core_ex.py index 6eb7e1b6..2fd3e6ba 100644 --- a/src/core_ex.py +++ b/src/core_ex.py @@ -231,3 +231,9 @@ class CallLater(object): Interval = property(GetInterval) Result = property(GetResult) + +#---------------------------------------------------------------------------- + +PyAssertionError = wx.wxAssertionError # an alias for compatibility with Classic + +#---------------------------------------------------------------------------- diff --git a/unittests/test_asserts.py b/unittests/test_asserts.py index bf800f41..51728cde 100644 --- a/unittests/test_asserts.py +++ b/unittests/test_asserts.py @@ -7,7 +7,8 @@ import wx class asserts_Tests(wtc.WidgetTestCase): def test_asserts1(self): - wx.PyAssertionError + wx.wxAssertionError + wx.PyAssertionError # a compatibility alias for wxAssertionError wx.APP_ASSERT_SUPPRESS wx.APP_ASSERT_EXCEPTION wx.APP_ASSERT_DIALOG @@ -20,7 +21,7 @@ class asserts_Tests(wtc.WidgetTestCase): # attempting to convert an invalid bitmap to an image is an easy way # to trigger an assert - with self.assertRaises(wx.PyAssertionError): + with self.assertRaises(wx.wxAssertionError): wx.NullBitmap.ConvertToImage() @@ -31,7 +32,7 @@ class asserts_Tests(wtc.WidgetTestCase): # ...and then turned back on wx.GetApp().SetAssertMode(wx.APP_ASSERT_EXCEPTION) - with self.assertRaises(wx.PyAssertionError): + with self.assertRaises(wx.wxAssertionError): wx.NullBitmap.ConvertToImage()