This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author CensoredUsername
Recipients CensoredUsername
Date 2014-12-20.23:24:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1419117872.02.0.125928182025.issue23094@psf.upfronthosting.co.za>
In-reply-to
Content
If a pickle frame ends at the end of a pickle._Unframer.readline() call then an UnpicklingError("pickle exhausted before end of frame") will unconditionally be raised due to a faulty check if the frame ended before the line ended.

It concerns this conditional in pickle._Unframer.readline, line 245 in pickle.py:

if data[-1] != b'\n':
    raise UnpicklingError(
        "pickle exhausted before end of frame")

This comparison will always evaluate to True even if data ends in a newline. This is caused by data being a bytes object, and such data[-1] will evaluate to 10 in case of data ending in a newline. 10 != b'\n' will then always evaluate to True due to the type mismatch, and the UnpicklingError will be raised.

This error can be corrected by slicing an actual one character bytes object like:

if data[-1:] != b'\n':
    raise UnpicklingError(
        "pickle exhausted before end of frame")

Or by comparing against the numeric representation of b'\n':

if data[-1] != b'\n'[0]:
    raise UnpicklingError(
        "pickle exhausted before end of frame")
History
Date User Action Args
2014-12-20 23:24:32CensoredUsernamesetrecipients: + CensoredUsername
2014-12-20 23:24:32CensoredUsernamesetmessageid: <1419117872.02.0.125928182025.issue23094@psf.upfronthosting.co.za>
2014-12-20 23:24:31CensoredUsernamelinkissue23094 messages
2014-12-20 23:24:31CensoredUsernamecreate