CensoredUsername added the comment:
Indeed. In my case the problem was caused a subclassed Pickler which still used
GLOBAL instead of STACK_GLOBAL in protocol 4.
My own minimized test case was:
data = b\x80\x04\x95\x11\x00\x00\x00\x00\x00\x00\x00cpickle\nPickler\n.
pickletools.dis(data
New submission from CensoredUsername:
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