import pickle
for arg in args:
print(arg)
pickle.dumps(arg)
I found that pickle raises the same exceptions as cPickle, but, since it's all Python, lets you set breakpoints around the exception to find out what's going on.
The ModuleImportFailure for example comes from python's system-wide unittest/loader.py from a function called _make_failed_import_test where it's dynamically created and hence can't be pickled. Setting a breakpoint inside that method around the error message should give you the required pointers to fix the import and thus the pickle exception.
For anyone else coming here and debugging pickle exceptions: another failure I ran into was from calling unittest.TestCase.addCleanup() with an instancemethod, e.g. something like self.addCleanup(self.remove_things). Making self.remove_things a global function fixed this too.
Hope this helps!