diff --git a/CHANGES.rst b/CHANGES.rst index 9b904982..84381309 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -102,6 +102,9 @@ Changes in this release include the following: * Change winid parameter in wx.ScrolledWindow to id, for consistency. (#816) +* Ensure that the page exists in book controls GetPage and RemovePage methods. + At least one of the wx ports do not do this. (#830) + diff --git a/etg/bookctrl.py b/etg/bookctrl.py index 5948e2c9..7c56a74f 100644 --- a/etg/bookctrl.py +++ b/etg/bookctrl.py @@ -42,6 +42,21 @@ def run(): c.find('HitTest.flags').out = True + # Workaround the lack of checking valid page numbers in wxGTK. + c.addPyCode("""\ + def _checkBookPageCount(f): + import functools + @functools.wraps(f) + def wrapper(self, page): + if page >= self.GetPageCount(): + raise wx.PyAssertionError("invalid notebook page") + return f(self, page) + return wrapper + + BookCtrlBase.RemovePage = _checkBookPageCount(BookCtrlBase.RemovePage) + BookCtrlBase.GetPage = _checkBookPageCount(BookCtrlBase.GetPage) + """) + #----------------------------------------------------------------- tools.doCommonTweaks(module)