Hello Christian,
The second patch you proposed is in subversion with a minimal test as
well. There are various other changes to ConfigObj - all around the
handling of configspecs, so I'd appreciate you checking that there are
no issues with the new version.
https://svn.pythonutils.python-hosting.com/trunk/pythonutils/configobj.py
All the best,
Michael Foord
Christian Heimes wrote:
> Dear Michael!
>
> I run into some trouble when I used a ConfigObj object as an argument
> to parallel python. After some debugging I spotted a design issue in
> your code.
>
> configobj.Section is a subclass of dict but it doesn't overwrite the
> pickle hook __reduce__. Pickling a section or configobj keeps the data
> in self (aka the dict) but not the data in self.__dict__. I came up
> with a quick hotfix for the problem.
>
> # ---
> import configobj
> import copy_reg
>
> def configobj_factory(cls):
> return cls.__new__(cls)
>
> copy_reg.constructor(configobj_factory)
>
> class SectionPatch(object):
>
> def __setstate__(self, state):
> dict.update(self, state[0])
> self.__dict__.update(state[1])
>
> def __reduce__(self):
> state = (dict(self), dict(self.__dict__))
> return (configobj_factory, (self.__class__, ), state)
>
> def patch(cls, patchcls):
> bases = cls.__bases__
> if not patchcls in bases:
> cls.__bases__ = (patchcls,) + bases
>
> patch(configobj.Section, SectionPatch)
> # ---
>
> Greeting
> Christian
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
|