Problem with Python 3.12 on Windows

Hi there

I’m currently transporting to Python 3.12. Then, I hit a small wall to overcome where the process takes a few seconds to terminate.

The test code:

#! python3 -Wd -Xdev -Xtracemalloc
import wx

will output the following error message on exit:

Fatal Python error: _PyMem_DebugFree: Python memory allocator called without holding the GIL
Python runtime state: finalizing (tstate=0x00007ffccc272fe8)

Tested with wxPython 4.2.1 / Python 3.12.1 on Windows 10.

I don’t see where the problem should be addressed.
I’m not sure, but the problem may be related to recent posts:

Hey @komoto48g this was actually a sip bug with Python 3.12 that has been fixed by upgrading sip. It’s been fixed in git, but not yet released in a wxPython release. I’ve been trying to bug @Robin to make a new release, but no luck yet.

Thanks @swt2c, it is very good news!
Confirmed that there is no error message when exiting.
Issues #2479 and #2455 seemed to be the relevant ones.

WxPython-4.2.2a1 wheel for Windows Python 3.12 has gone from the unofficial snapshot folder.
So, for Windows users who want to avoid the Python 3.12 issue, I’d like to note how to download the latest snapshot build from Azure pipelines:

  1. Click the topmost (latest) build item.
  2. Select the proper version.
  3. Click “1 artifact produced” link.
  4. Download the zip file from the right side dots menu:
1 Like