[mod_python] Session Pickling Error II - 3.2.2b

Graham Dumpleton grahamd at dscpl.com.au
Tue Oct 4 02:16:07 EDT 2005

Nicolas Lehuen wrote ..
> As explained in the error message, function objects can't be pickled. This
> is not a mod_python limitation, rather a Python limitation.

Hmmm, the pickle module documentation at:



  The following types can be pickled:


     - functions defined at the top level of a module

It does however say:

  Note that functions (built-in and user-defined) are pickled by ``fully
  qualified'' name reference, not by value. This means that only the
  function name is pickled, along with the name of module the function is
  defined in. Neither the function's code, nor any of its function
  attributes are pickled. Thus the defining module must be importable in
  the unpickling environment, and the module must contain the named
  object, otherwise an exception will be raised.

Note the requirement on the module being importable in the unpickling
environment. Since it wasn't imported and present in "sys.modules" to
begin with, I would say it is able to detect the potential for problems at
pickling time instead of later.

But then, I could still be wrong. :-)


More information about the Mod_python mailing list