BUG: ndarrays pickled by 1.16 cannot be loaded by 1.15.4 and lower #12869
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #12842.
Fixes #12837
When pickling ndarrays, the pickle protocol adds the reconstructing function's module
name to the pickled string so it can be called. The function (which is
_reconstruct) now lives in
numpy.core._multiarray_umath, but in pre-1.16 numpy it was in
numpy.core.multiarray. Also for scalar objects, the function
scalar` moved.The fix is very simple, changing the
__module__
attribute of_reconstruct
andscalar
In
array_reduce_ex
, used when the pickle protocol is 5, the function will benumpy.core.numeric._frombuffer
, which will not exist on pre-1.16 numpy (added in commit 64a855f, Oct 2018). I don't think we can work around that. People who do not have that function will have to modify their numpy if they wish to import protocol-5 pickled ndarrays.