Internal error bug report

Here is a nice doozy of a bug report. I am managing to
get some sort of internal error in wxPython (windows only)
where it is returning the last error that happened in some
other code to code running in an OnIdle handler.

To reproduce, run the attached file. Click on the button.
A dialog will appear. Click in the top combobox and select
"Home" or "Business". Now click in it again and select the
first (blank) entry.

You will get the stacktrace below:

Traceback (most recent call last):
  File "t.py", line 23, in OnIdle
    self.Reposition()
  File "t.py", line 26, in Reposition
    rect=self.GetFieldRect(2)
  File "C:\Python23\Lib\site-packages\wxPython\stattool.py", line 27, in GetFiel
dRect
    val = stattoolc.wxStatusBar_GetFieldRect(self, *_args, **_kwargs)
wxPython.wxc.wxPyAssertionError: C++ assertion "wxAssertFailure" failed in e:\Pr
ojects\wx2.4\src\common\choiccmn.cpp(54): invalid string in wxChoice::SetStringS
election

The SetStringSelection error is actually from the one that was caught in
the constructor for the dialog box, and nothing whatsoever to do with
the actual code being shown (getting a rectangle for a part of a statusbar
field).

The code in t.py is somewhat ugly as bits of it were hacked out of my
real code. I never thought I would be able to reproduce this in a small
example!

Roger

t.py (1.62 KB)

Roger Binns wrote:

Here is a nice doozy of a bug report.

No kidding.

I am managing to
get some sort of internal error in wxPython (windows only)
where it is returning the last error that happened in some
other code to code running in an OnIdle handler.

To reproduce, run the attached file. Click on the button.
A dialog will appear. Click in the top combobox and select
"Home" or "Business". Now click in it again and select the
first (blank) entry.

You will get the stacktrace below:

Traceback (most recent call last):
  File "t.py", line 23, in OnIdle
    self.Reposition()
  File "t.py", line 26, in Reposition
    rect=self.GetFieldRect(2)
  File "C:\Python23\Lib\site-packages\wxPython\stattool.py", line 27, in GetFiel
dRect
    val = stattoolc.wxStatusBar_GetFieldRect(self, *_args, **_kwargs)
wxPython.wxc.wxPyAssertionError: C++ assertion "wxAssertFailure" failed in e:\Pr
ojects\wx2.4\src\common\choiccmn.cpp(54): invalid string in wxChoice::SetStringS
election

The SetStringSelection error is actually from the one that was caught in
the constructor for the dialog box, and nothing whatsoever to do with
the actual code being shown (getting a rectangle for a part of a statusbar
field).

Not quite. There is an internal call to SetStringSelection when the item is selected, and the wxASSERT is called at that time and then turned into a Python exception which will wait until the next C++ --> Python transition before the exception is raised. In most cases that happens almost immediately when whatever you called that caused the exception returns, but in this case that next transition is in the EVT_IDLE handler after the first C++ call (GetFieldRect.)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!