Exceptions in Dialog??

31 views
Skip to first unread message

Chris Barker

unread,
Sep 27, 2023, 9:33:44 PM9/27/23
to wxpython-users
Hey all,

I'm trying to update a old App ,written quite some years ago (py2.7, and whih knows how old a wxPython).

I got it to run, but now whenever it hits an Exception (presumably in an event handler) -- I get a dialog with the error -- but it doesn' print to the console, and it doesn't provide a traceback, so it's really hard to debug!

Is this a new(ish) feature -- and if so, how can I turn it off? -- I really need to see the tracebacks.

-CHB


--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris....@noaa.gov

Tim Roberts

unread,
Sep 27, 2023, 11:43:24 PM9/27/23
to 'Chris Barker' via wxPython-users
On 9/27/23 6:33 PM, 'Chris Barker' via wxPython-users wrote:

> Hey all,
>
> I'm trying to update a old App ,written quite some years ago (py2.7,
> and whih knows how old a wxPython).
>
> I got it to run, but now whenever it hits an Exception (presumably in
> an event handler) -- I get a dialog with the error -- but it doesn'
> print to the console, and it doesn't provide a traceback, so it's
> really hard to debug!
>
> Is this a new(ish) feature -- and if so, how can I turn it off? -- I
> really need to see the tracebacks.

The dialog includes the traceback, and you should be able to cut and paste.

They did that mostly for Windows, where a GUI app doesn't have a console
at all.

--

Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

niki

unread,
Sep 28, 2023, 2:55:20 AM9/28/23
to 'Chris Barker' via wxPython-users
On 28.09.23 г. 4:33 ч., 'Chris Barker' via wxPython-users wrote:
> Hey all,
>
> I'm trying to update a old App ,written quite some years ago (py2.7, and
> whih knows how old a wxPython).
>
> I got it to run, but now whenever it hits an Exception (presumably in an
> event handler) -- I get a dialog with the error -- but it doesn' print
> to the console, and it doesn't provide a traceback, so it's really hard
> to debug!
>
> Is this a new(ish) feature -- and if so, how can I turn it off? -- I
> really need to see the tracebacks.

You can experiment with

app.SetAssertMode(
#~ wx.PYAPP_ASSERT_DIALOG
wx.PYAPP_ASSERT_EXCEPTION
)

HTH
Niki

Chris Barker

unread,
Sep 28, 2023, 11:59:44 AM9/28/23
to wxpytho...@googlegroups.com
On Wed, Sep 27, 2023 at 8:43 PM Tim Roberts <ti...@probo.com> wrote:
> I got it to run, but now whenever it hits an Exception (presumably in
> an event handler) -- I get a dialog with the error -- but it doesn'
> print to the console, and it doesn't provide a traceback, so it's
> really hard to debug!
>
> Is this a new(ish) feature -- and if so, how can I turn it off? -- I
> really need to see the tracebacks.
 
The dialog includes the traceback, and you should be able to cut and paste.

If only. On the Mac, this is all I get:

image.png
 
They did that mostly for Windows, where a GUI app doesn't have a console
at all.

Nor does it on a Mac -- though the Mac does have a system console that catches stderr -- I'll go look there, and try NIki's suggestion.

Is this wxWidgets C++ code? If so, I can go ask there. It seem the lack of access to the traceback is a big missing feature on the Mac :-(

Thanks,

-CHB

 

--

Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/4fdaafae-b9f4-5689-c6c8-3ab775227de3%40probo.com.

Chris Barker

unread,
Sep 28, 2023, 7:36:54 PM9/28/23
to wxpytho...@googlegroups.com
Well Darn,

Setting the AsserMode didn't change a thing -- I tried all values:

    # A.SetAssertMode(# wx.APP_ASSERT_SUPPRESS
    #                 # wx.APP_ASSERT_EXCEPTION
    #                 # wx.APP_ASSERT_DIALOG
    #                 wx.APP_ASSERT_LOG
    #                 )
none of them made any difference.

Should I call it after starting the MainLoop? that doesn't seem right :-(

I seem to have found two issues (at least on wxMac):
(wPython 4.2.1 on Python 3.11 on wxMac)

1) The Error Dialog that pops up when an Exception occurs inside an event handler (I assume...) provides now way to see the traceback.

2) There appears to be no way to set it to send errors to the console.

Any more ideas? Is this only an issue on the Mac?

Thanks,
-Chris





Chris Barker

unread,
Sep 28, 2023, 8:36:34 PM9/28/23
to wxpytho...@googlegroups.com
False Alarm -- it was all our code.

I did NOT write this, but there was a:

except Exception:
     [put up a dialog with the message]

In there. It was intended to catch known exceptions with reasonable messages, but, of course, it was catching everything :-(

Even worse, the known exceptions were being raised as:

raise Exception("Some nice message here")

I REALLY need to do more code review when Python newbies are working on something!

Thanks for your hints anyway....

Sheepishly yours,

-Chris

For the record, it sumps the traceback to the console by default, and if I call:

App.SetAssertMode(wx.APP_ASSERT_DIALOG)

So there's that :-)
Reply all
Reply to author
Forward
0 new messages