Python Forum

Full Version: Handling Python Fatal Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I have been trying to handle errors in my python code using try & except, but this is not able to handle refcount error which causes my application to crash.

The error I get is:

Fatal Python error: deallocating None

Current thread 0x00007f93428bb700 (most recent call first):
<Stack Trace which is not helping>


How can I handle this kind of error? Or how to identify the root cause for this?

Any help will be appreciated. Thanks.
Please show an actual python traceback (error message)
unaltered and complete, within bbcode error tags
(Feb-10-2021, 06:25 PM)Larz60+ Wrote: [ -> ]Please show an actual python traceback (error message)
unaltered and complete, within bbcode error tags

Here is the complete error:

Error:
Fatal Python error: deallocating None Current thread 0x00007f22d5148700 (most recent call first): Thread 0x00007f27115dab80 (most recent call first): File "/usr/lib/python3/dist-packages/gi/overrides/GLib.py", line 585 in run File "myapp.py", line 271 in glib_mainloop File "myapp.py", line 244 in main File "myapp.py", line 302 in <module>
This error message still looks incomplete as there is no link back to your code (no traceback) which is what I was looking for.
So unfortunately it doesn't help much.
was there a part of the message not included?
(Feb-11-2021, 09:55 AM)Larz60+ Wrote: [ -> ]This error message still looks incomplete as there is no link back to your code (no traceback) which is what I was looking for.
So unfortunately it doesn't help much.
was there a part of the message not included?

This is all I get in the error. myapp.py is my application python source.
Can't say without seeing code.
Looks like an error in the glib wrapper. Without knowing what you're doing, we'd just be making guesses.
Sorry for reviving an old thread. I just figured out what this error means after many hours of digging, and it frustrates me that I couldn't find good documentation on the error itself. This seems like a very easy mistake to make.

None is a special, global object. What "deallocating None" means is that the reference count on "None" has reached 0, and None is to be deallocated (AKA deleted). This is a bad thing! It likely means that a Python library written in C/C++ is returning Py_None for use in Python proper without first calling Py_INCREF(Py_None). The error then shows itself elsewhere in code because the ref count on None is now 1 too few. When someone throws away its reference to None, only then will this error present itself. It may or may not be a problem in GLib.py if this is the case.