Python - C++ problen determination
-
- In need of some credit
- Posts: 6
- Joined: Mon Feb 15, 2021 4:24 pm
Python - C++ problen determination
I am experiencing spurious problems that show up as a C++ assertion exception.
It is always the same problem, it mostly occurs when I open the lid of my laptop during execution of my application. It might well have to do with a repaint operation when opening the lid.
I am using PyCharm and running on Windows 10 and fairly up-to-date versions of Python and wxPython.
My problem is, how do I find out what the problem is ?
wx._core.wxAssertionError: C++ assertion "(argtype & (wxFormatStringSpecifier<T>::value)) == argtype" failed at C:\PROJECTS\bb2\dist-win64-py39\build\ext\wxWidgets\include\wx/strvararg.h(484) in wxArgNormalizer<unsigned __int64>::wxArgNormalizer(): format specifier doesn't match argument type
The above exception was the direct cause of the following exception:
SystemError: <class 'wx._core.MouseEvent'> returned a result with an error set
Cheers, Adrian
It is always the same problem, it mostly occurs when I open the lid of my laptop during execution of my application. It might well have to do with a repaint operation when opening the lid.
I am using PyCharm and running on Windows 10 and fairly up-to-date versions of Python and wxPython.
My problem is, how do I find out what the problem is ?
wx._core.wxAssertionError: C++ assertion "(argtype & (wxFormatStringSpecifier<T>::value)) == argtype" failed at C:\PROJECTS\bb2\dist-win64-py39\build\ext\wxWidgets\include\wx/strvararg.h(484) in wxArgNormalizer<unsigned __int64>::wxArgNormalizer(): format specifier doesn't match argument type
The above exception was the direct cause of the following exception:
SystemError: <class 'wx._core.MouseEvent'> returned a result with an error set
Cheers, Adrian
Re: Python - C++ problen determination
The assert complains about a type mispatch between a format specifier in a printf command and the passed parameter. E.g. using "%d", but passing a 64bit integer value.
But i can't tell if this is caused by wxPython or your code. Can you get a complete call stack?
But i can't tell if this is caused by wxPython or your code. Can you get a complete call stack?
Use the source, Luke!
-
- In need of some credit
- Posts: 6
- Joined: Mon Feb 15, 2021 4:24 pm
Re: Python - C++ problen determination
Thanks !
Well, that's my problem, I don't see any call stack !
From a Python point of view, how do I get a C++ call stack ?
Or, if you want a Python stack, how can I intercept errors like these in Python ?
Cheers, Adrian
Well, that's my problem, I don't see any call stack !
From a Python point of view, how do I get a C++ call stack ?
Or, if you want a Python stack, how can I intercept errors like these in Python ?
Cheers, Adrian
Re: Python - C++ problen determination
I don't use wxPython, so unfortunately i don't know.
First of all: Do you have any mouse event handlers, or any wxString::Format/Printf outputs in your code? If not, try with a minimal wxPython sample and check if it has the same issue. If yes, the problem lies inside wxPython, and you could open a bug report (issue) here: https://github.com/wxWidgets/Phoenix/issues
First of all: Do you have any mouse event handlers, or any wxString::Format/Printf outputs in your code? If not, try with a minimal wxPython sample and check if it has the same issue. If yes, the problem lies inside wxPython, and you could open a bug report (issue) here: https://github.com/wxWidgets/Phoenix/issues
Use the source, Luke!
-
- In need of some credit
- Posts: 6
- Joined: Mon Feb 15, 2021 4:24 pm
Re: Python - C++ problen determination
After reading the last message again, it sounds to me that <class 'wx._core.MouseEvent'> returned an error indication and that somewhere a subsequent attempt to record this error caused the assertion being triggered.
My question is, can the error indication have been caused by any of my mouse event handler ?
If so, do mouse event handler have to return a value, what are acceptable return values ?
Cheers, Adrian
My question is, can the error indication have been caused by any of my mouse event handler ?
If so, do mouse event handler have to return a value, what are acceptable return values ?
Cheers, Adrian
Re: Python - C++ problen determination
Theoretically, yes. That's why i asked if you have any.Adrian2511 wrote: ↑Tue Feb 16, 2021 11:02 am My question is, can the error indication have been caused by any of my mouse event handler ?
No. Event handlers don't have return values (at least on the C++ side).If so, do mouse event handler have to return a value, what are acceptable return values ?
Use the source, Luke!
-
- In need of some credit
- Posts: 6
- Joined: Mon Feb 15, 2021 4:24 pm
Re: Python - C++ problen determination
I do have a number of mouse event handler:
self.canvas.Bind(wx.EVT_LEFT_DOWN, onMouseLeftDown)
self.canvas.Bind(wx.EVT_RIGHT_DOWN, onMouseRightDown)
self.canvas.Bind(wx.EVT_MIDDLE_DOWN, onMouseMiddleDown)
self.canvas.Bind(wx.EVT_LEFT_UP, onMouseLeftUp)
self.canvas.Bind(wx.EVT_MOTION, self.onMotion)
self.canvas.Bind(wx.EVT_MOUSEWHEEL, self.onMouseWheel)
self.canvas.Bind(wx.EVT_LEAVE_WINDOW, self.onLeaveWindow)
self.canvas.Bind(wx.EVT_ENTER_WINDOW, self.onEnterWindow)
I did the following tests:
Test A:
1. I started the application and moved the mouse pointer away from the application
The app shows a couple simple vector drawings
2. I closed the lid of my laptop
3. After 10 seconds I opened my laptop
4. the app shows up and receives onSize and onPaint events
5. Up to now, no mouse events have occurred because the mouse pointer was outside of the app's window
6. When I moved the mouse pointer inside the app's window the the error as described occurs
Test B:
I was suspecting the following bindings:
self.canvas.Bind(wx.EVT_MOTION, self.onMotion)
self.canvas.Bind(wx.EVT_LEAVE_WINDOW, self.onLeaveWindow)
self.canvas.Bind(wx.EVT_ENTER_WINDOW, self.onEnterWindow)
I inserted return statements at the beginning of the three handlers and did steps 1 thru 6 again
I got the following:
wx._core.wxAssertionError: C++ assertion "(argtype & (wxFormatStringSpecifier<T>::value)) == argtype" failed at C:\PROJECTS\bb2\dist-win64-py39\build\ext\wxWidgets\include\wx/strvararg.h(484) in wxArgNormalizer<unsigned __int64>::wxArgNormalizer(): format specifier doesn't match argument type
The above exception was the direct cause of the following exception:
SystemError: <class 'property'> returned a result with an error set
Notice the last line: <class property> had a problem
Test C:
I commented these bindings
# self.canvas.Bind(wx.EVT_LEAVE_WINDOW, self.onLeaveWindow)
# self.canvas.Bind(wx.EVT_ENTER_WINDOW, self.onEnterWindow)
I did steps 1 thru 6 again and got the same problem as test B
Notice that during test B and test C the mouse motion handler looked like this:
def onMotion(self, ev):
# print('onMotion()')
return
x, y = self.m2wPos(ev.x, MainFrame.winH - ev.y)
etc, etc ,etc
Test D:
I commented the motion binding
# self.canvas.Bind(wx.EVT_MOTION, self.onMotion)
I did steps 1 thru 6 again and got no problems
Test E:
I uncommented the enter window binding
self.canvas.Bind(wx.EVT_ENTER_WINDOW, self.onEnterWindow)
I did steps 1 thru 6 again and got <class property> error again
wx._core.wxAssertionError: C++ assertion "(argtype & (wxFormatStringSpecifier<T>::value)) == argtype" failed at C:\PROJECTS\bb2\dist-win64-py39\build\ext\wxWidgets\include\wx/strvararg.h(484) in wxArgNormalizer<unsigned __int64>::wxArgNormalizer(): format specifier doesn't match argument type
The above exception was the direct cause of the following exception:
SystemError: <class 'property'> returned a result with an error set
For all tests I made sure the mouse was away from the app window before app really started. I managed to this because I started the app from within the PyCharm IDE. The IDE needs time to let the app run.
So the moving of the cursor into the the app's window caused the very first mouse events to occur
What does that tell us ?
Cheers, Adrian
self.canvas.Bind(wx.EVT_LEFT_DOWN, onMouseLeftDown)
self.canvas.Bind(wx.EVT_RIGHT_DOWN, onMouseRightDown)
self.canvas.Bind(wx.EVT_MIDDLE_DOWN, onMouseMiddleDown)
self.canvas.Bind(wx.EVT_LEFT_UP, onMouseLeftUp)
self.canvas.Bind(wx.EVT_MOTION, self.onMotion)
self.canvas.Bind(wx.EVT_MOUSEWHEEL, self.onMouseWheel)
self.canvas.Bind(wx.EVT_LEAVE_WINDOW, self.onLeaveWindow)
self.canvas.Bind(wx.EVT_ENTER_WINDOW, self.onEnterWindow)
I did the following tests:
Test A:
1. I started the application and moved the mouse pointer away from the application
The app shows a couple simple vector drawings
2. I closed the lid of my laptop
3. After 10 seconds I opened my laptop
4. the app shows up and receives onSize and onPaint events
5. Up to now, no mouse events have occurred because the mouse pointer was outside of the app's window
6. When I moved the mouse pointer inside the app's window the the error as described occurs
Test B:
I was suspecting the following bindings:
self.canvas.Bind(wx.EVT_MOTION, self.onMotion)
self.canvas.Bind(wx.EVT_LEAVE_WINDOW, self.onLeaveWindow)
self.canvas.Bind(wx.EVT_ENTER_WINDOW, self.onEnterWindow)
I inserted return statements at the beginning of the three handlers and did steps 1 thru 6 again
I got the following:
wx._core.wxAssertionError: C++ assertion "(argtype & (wxFormatStringSpecifier<T>::value)) == argtype" failed at C:\PROJECTS\bb2\dist-win64-py39\build\ext\wxWidgets\include\wx/strvararg.h(484) in wxArgNormalizer<unsigned __int64>::wxArgNormalizer(): format specifier doesn't match argument type
The above exception was the direct cause of the following exception:
SystemError: <class 'property'> returned a result with an error set
Notice the last line: <class property> had a problem
Test C:
I commented these bindings
# self.canvas.Bind(wx.EVT_LEAVE_WINDOW, self.onLeaveWindow)
# self.canvas.Bind(wx.EVT_ENTER_WINDOW, self.onEnterWindow)
I did steps 1 thru 6 again and got the same problem as test B
Notice that during test B and test C the mouse motion handler looked like this:
def onMotion(self, ev):
# print('onMotion()')
return
x, y = self.m2wPos(ev.x, MainFrame.winH - ev.y)
etc, etc ,etc
Test D:
I commented the motion binding
# self.canvas.Bind(wx.EVT_MOTION, self.onMotion)
I did steps 1 thru 6 again and got no problems
Test E:
I uncommented the enter window binding
self.canvas.Bind(wx.EVT_ENTER_WINDOW, self.onEnterWindow)
I did steps 1 thru 6 again and got <class property> error again
wx._core.wxAssertionError: C++ assertion "(argtype & (wxFormatStringSpecifier<T>::value)) == argtype" failed at C:\PROJECTS\bb2\dist-win64-py39\build\ext\wxWidgets\include\wx/strvararg.h(484) in wxArgNormalizer<unsigned __int64>::wxArgNormalizer(): format specifier doesn't match argument type
The above exception was the direct cause of the following exception:
SystemError: <class 'property'> returned a result with an error set
For all tests I made sure the mouse was away from the app window before app really started. I managed to this because I started the app from within the PyCharm IDE. The IDE needs time to let the app run.
So the moving of the cursor into the the app's window caused the very first mouse events to occur
What does that tell us ?
Cheers, Adrian
Re: Python - C++ problen determination
So it only happens with EVT_MOTION?
Do you call evt.Skip() in the event handler? If not, please try that.
In any case, i think you need an wxPython expert Try https://discuss.wxpython.org/ or the wx-users Google group: https://groups.google.com/g/wx-users
Do you call evt.Skip() in the event handler? If not, please try that.
How is your laptop configured, what does it do when you close the lid? Does it just switch off the screen, does it go into sleep mode, or what?I closed the lid of my laptop
In any case, i think you need an wxPython expert Try https://discuss.wxpython.org/ or the wx-users Google group: https://groups.google.com/g/wx-users
Use the source, Luke!
-
- In need of some credit
- Posts: 6
- Joined: Mon Feb 15, 2021 4:24 pm
Re: Python - C++ problen determination
When I close the lid, the system goes to sleep
In test A I got: SystemError: <class 'wx._core.MouseEvent'> returned a result with an error set
in test B, C and E I got: SystemError: <class 'property'> returned a result with an error set
Independent of your Python remark, do you mean I have to use evt.Skip(), or do you mean I should try it ?
Cheers, Adrian
In test A I got: SystemError: <class 'wx._core.MouseEvent'> returned a result with an error set
in test B, C and E I got: SystemError: <class 'property'> returned a result with an error set
Independent of your Python remark, do you mean I have to use evt.Skip(), or do you mean I should try it ?
Cheers, Adrian
-
- In need of some credit
- Posts: 6
- Joined: Mon Feb 15, 2021 4:24 pm
Re: Python - C++ problen determination
I tried evt.Skip() for test E, only the EVT_ENTER_WINDOW handler being bound.
Without evt.Skip(), I got the message SystemError: <class 'property'> returned a result with an error set
With evt.Skip(), I got the message: SystemError: <class 'wx._core.MouseEvent'> returned a result with an error set
Thanks for your help, I will try somewhere else.
Cheers, Adrian
Without evt.Skip(), I got the message SystemError: <class 'property'> returned a result with an error set
With evt.Skip(), I got the message: SystemError: <class 'wx._core.MouseEvent'> returned a result with an error set
Thanks for your help, I will try somewhere else.
Cheers, Adrian
Re: Python - C++ problen determination
That depends on what you wantIndependent of your Python remark, do you mean I have to use evt.Skip(), or do you mean I should try it ?
The name Skip() doesn't make very clear what it does, assume it's called ContinueProcessing(). Without event.Skip() you "consume" the event, no other event handler will be called for it.
For mouse events ( wxEVT_LEFT_DOWN, wxEVT_LEFT_UP, etc) you usually want to call Skip().
For command events (wxEVT_BUTTON, etc) you usually don't.
Use the source, Luke!