[issue39681] pickle.load expects an object that implements readinto

Nathan Goldbaum report at bugs.python.org
Wed Feb 19 10:50:39 EST 2020


Nathan Goldbaum <nathan12343 at gmail.com> added the comment:

In this case the tests are explicitly testing that a file-like object that does not implement readinto works with torch.load (which is using pickles under the hood). See https://github.com/pytorch/pytorch/blob/master/test/test_serialization.py#L416-L429, in particular the usage of FilelikeMock with has_readinto set to False.

This goes back to https://github.com/pytorch/pytorch/pull/5466, however I'm not sure offhand why it was decided to explicitly test file-like objects that don't implement readinto. I don't know how many consumers there are for this API in pytorch, but there is at least one user who has reported an error traceback caused by this change. I'm hoping to hear more to see whether there are any libraries that depend on pytorch and are implicitly depending on this functionality.

Googling the error message that Python3.8 emits in this situation also leads me to this bug report in a different library: https://github.com/web2py/py4web/issues/77

----------

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


More information about the Python-bugs-list mailing list