Merge pull request #832 from RobinD42/fix-issue820

Workaround the lack of checking valid page numbers in book ctrls
This commit is contained in:
Robin Dunn
2018-04-28 20:48:26 -07:00
parent 47e32c0d33
commit 21fc134bd7
2 changed files with 18 additions and 0 deletions

View File

@@ -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)