Message 306289 - Python tracker (original) (raw)

My first fix was indeed wrong. Upon looking further into it, it seems to me that the problem come from the fact that the call to super is not done with the right argument. Upon unpickling, the argument that will be passed to the init is the string representation built on line 33-34. That's why, when leaving expected as optional the number returned is 44, the length of the string.

I went looking for similar Exception class in the code base and found the MaybeEncodingError in multiprocessing/pool.py

By replacing the Error content with this one I don't have any error anymore. The message is kept identical. ''' def init(self, partial, expected): super().init(partial, expected) self.partial = partial self.expected = expected def str(self): return ("%d bytes read on a total of %r expected bytes" % (len(partial), expected)) '''

Does such a fix looks correct to you ?