>>> import cPickle
>>> cPickle.loads(b"S' \np0\n.")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: Negative size passed to PyString_FromStringAndSize
>>> pickle.loads(b"S' \np0\n.")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/serhiy/py/cpython2.7/Lib/pickle.py", line 1382, in loads
return Unpickler(file).load()
File "/home/serhiy/py/cpython2.7/Lib/pickle.py", line 858, in load
dispatch[key](self)
File "/home/serhiy/py/cpython2.7/Lib/pickle.py", line 966, in load_string
raise ValueError, "insecure string pickle"
ValueError: insecure string pickle
>>> cPickle.loads(b"S'\np0\n.")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: Negative size passed to PyString_FromStringAndSize
>>> pickle.loads(b"S'\np0\n.")
''
Python 3 has the same behavior except C implementation raises UnpicklingError for b"S'\np0\n.".