[issue32034] Error when unpickling IncompleteReadError

badouxn report at bugs.python.org
Wed Nov 15 12:32:49 EST 2017


badouxn <badouxn at ethz.ch> added the comment:

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 ?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32034>
_______________________________________


More information about the Python-bugs-list mailing list