Problem with Panda3d objects' "__module__" attribute

I’m having trouble pickling some Panda3d objects that never gave me trouble before, and I think the source of the issue is the objects’ “module” attribute not containing the full module string. I believe “pickle” uses module to find necessary information for serializing the object, so when it can’t find it, it errors. I’m using Ubuntu 14.04 (Trusty) 64, Panda3d from koudelka’s build in this post: Compile SDK (Ubuntu 14.04 Beta) , updated drivers etc. I also found a commit in the github repo from Oct 7 where the issue was not present. Unfortunately, I don’t have time to track down where the problem was introduced.

I ran the following commands on three recent builds, the first two showed the problem, the last (Oct 7) one did not and pickling worked OK:

  • koudelka’s build in this post: Compile SDK (Ubuntu 14.04 Beta)
  • a Feb 20 commit in the Github “incremental” repo (commit: efbf70a2931b5d94724d7b65f51d0e1c37fc148b)
  • a Oct 7 commit in the Github repo (commit: 2a664131da7f732e95816104a53c83f6f63b2459)
import panda3d.core
print(panda3d.core.Vec3)
print(panda3d.core.Vec3.__module__)
print(panda3d.core.NodePath)
print(panda3d.core.NodePath.__module__)

koudelka’s build and the Feb 20 build printed:

<type 'core.LVector3f'>
core
<type 'core.NodePath'>
core

The Oct 7 build printed:

<type 'libpanda.LVector3f'>
libpanda
<type 'libpanda.NodePath'>
libpanda

Here’s the pickle error on koudelka’s build and Feb 20 build:

import panda3d.core
import pickle
pickle.dumps(panda3d.core.Vec3(1, 2, 3))

Error text:

PicklingError: Can't pickle <type 'core.LVector3f'>: it's not found as core.LVector3f

Hmm, that is tricky, because we changed it so that the Python bindings are no longer in libpanda but in panda3d.core. I didn’t know the module name was necessary for pickling. I suppose I’ll have to change our binding generator to generate its built-in module strings as ‘panda3d.core.X’.

Poke me if I don’t get back to you about this soon.

I didn’t forget about this; I had already made the necessary changes in my local build, I just wanted to test them some more because the interrogate code wasn’t designed to accept full stops in the module name setting and I wasn’t sure how much would break. Thanks for reminding me to check them in.

I’ve just checked in my changes to CVS; will be on git in ~24 minutes and on the daily builds in ~24 hours.

Awesome, thanks a lot!