I have a python class whose instance variables may contain 'raw' Java objects and I need to serialize this class to/from a file. Since Pickle doesn't Pickle Java classes I followed the advice around this board and serialize using:
 
 def dumpf(self, obj, fname):
  """Serializes object to file"""
  io.ObjectOutputStream(io.FileOutputStream(fname)).writeObject(obj)
  
 def restoref(self, fname):
  """Restores serialized object in file"""
  inStream = org.python.util.PythonObjectInputStream(io.FileInputStream(fname)) 
  return inStream.readObject()  
 
However I seem to be having problems on the _dump_ side. Examining the binary file shows that certain instance variables aren't always showing up depending on their contents ('dict' objects seem unreliable in this regard - if an instance variable has value {} the variable doesn't appear at all in the binary).
 
Is there a reliable way of serializing an instance of a  Python class that may have raw Java objects in instance variables. I'm using Jython 2.1. on JDK 1.3 on Win 2K.
 
Tnx
Alanl