Migration to Python 3

I’ve been able to work around the segfault. It only occurs when I import libpandaexpress before libpanda, and not the other way around. Which baffles me, as libpandaexpress is a dependency of libpanda. Since I don’t have a debugging environment set up on the laptop that I do the Python 3 work on, I have no means to see what’s going on. But here’s some code that works for me:

import panda3d
mgr = panda3d.__manager__
mgr.libimport('libpanda')
mgr.libimport('libpandaexpress')
print("Imported")

from libpandaexpress import *
from libpanda import *

Presumably, simply swapping the libraries around in the definition for the ‘core’ module in panda3d.py will also work, but I won’t do that until I’ve found out why this happens. At some point in the future, I plan on doing a complete overhaul of the way we compile the Python bindings into the libraries, which may solve some of the problems we’re encountering, but it may not make much sense to wait for that unless I find time to get around to it soon.

I’m still getting another segfault, but it happens at shutdown, so I suppose it’s less important.

The next step for me would probably be to integrate the py2to3-based tool into makepanda. Can you send the script so that I can try it for myself?