[Tutor] cannot pickle instancemethod objects
Kent Johnson
kent37 at tds.net
Wed Jun 13 14:09:26 CEST 2007
hok kakada wrote:
>> What kind of object is matcher? Does it have any attributes that are
>> functions? (Not methods you defined for the class, but functions or
>> methods that you assign to attributes of self.)
> Actually, I use the translate-toolkit from
> http://translate.sourceforge.net/snapshots/translate-toolkit-1.0.1rc1/
> in translate/search/match.py:
> if comparer is None:
> comparer = lshtein.LevenshteinComparer(max_length)
> self.comparer = comparer
> I just found the problem that it is because of the LevenshteinComparer. Once I
> assign self.comparer = None, the I can dump the matcher successfully.
> However, I still don't understand what could be wrong with
> LevenshteinComparer.
I think the problem is this code in LevenshteinComparer.__init__():
if Levenshtein:
self.distance = self.native_distance
else:
self.distance = self.python_distance
which assigns an instance method to an instance attribute; this is the
instancemethod that can't be pickled.
Kent
PS Please use Reply All to reply to the list.
More information about the Tutor
mailing list