-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
on exit, freetype/__init__.py", line 1233, in __del__ TypeError: 'NoneType' object is not callable #169
Comments
Argh, I thought this has been discussed before, and it has: |
This can be a good task to learn about freetype. This can be investigated by building a debug version of freetype, set FT_DEBUG / FT_TRACE to see when and what freetype receives from freetype-py from the other side. This could fix some of the other issues with other At the moment we don't do anything in a few of |
I've been seeing reports for this error for a couple of years now microscope-cockpit/cockpit#684 (it's always when the program is exiting so we never paid much attention). Effectively, the error is at https://github.com/rougier/freetype-py/blob/ccd4f5fca0fb1dd69e40b2966db60139ec1c49da/freetype/__init__.py#LL1231C1-L1231C42 , i.e.:
And what is |
I tried to look deeper into this and even
There's stackoverflow questions and python bug reports about this (here's a similar Python bug report). Recommendation from Python itself seems to get a strong reference to the needed machinery before trying to use. I will open a pull request. |
That is nonsense. FT_Done_Face() is a binding of the shared library. What is quite likely is that FT_Done_Library() (which also calls FT_Done_Face() on the library side) is occasionally called automatically first before FT_Done_Face() by ctypes. The del face method probably should check the library handle and that FT_Done_Library() has not been called yet. Edit: hmm, on 2nd thought. I think it is really best to investigate with a debug build of freetype. |
Sorry, on another thought, since freetype itself hasn't segfaulted, the problem is entirely on the python side. There is the ctype object which holds the reference to the shares library, and the library pointer returned from FT_Init_Library(), both of these could go before the face object. |
…ne (rougier#169) When we're called during the interpreter shutdown, the functions we need may already be set to None. So check for that before trying to call them which fixes the "'NoneType' object is not callable" errors described in issues rougier#44 and rougier#169.
This is the testing I did that shows the issue. This is the diff:
and this is the output:
The error message is also clear. What is being called is This shows that the problem is that |
We probably need the case where FT_Done_Face is called. Otherwise it isn't better than simply deleting those lines. |
In the case where
|
freetype.Face.__del__: check first if FT_Face_Done has been set to None (#169)
With the pull request #171 this issue is fixed. There may be other issues with cleanup during runtime but the specific issue described here, i.e., "on exit, freetype/init.py", line 1233, in del TypeError: 'NoneType' object is not callable", is specific to "faces" during shutdown. |
This seems to be a race condition on exit - I often get:
The cure is, curious enough, explicitly doing
del face
at the end of the program. This seems to suggest that, maybe there is a bug somewhere about destructor's calling order, such as the library or other objects are destructed first (and destroying the face handle).The text was updated successfully, but these errors were encountered: