Created
February 28, 2020 08:24
-
-
Save Mulugruntz/2c668a70c50f8272bce0c208aaae924e to your computer and use it in GitHub Desktop.
ndarray gets filled with or without the buffer being specified. It seems to read some memory it shouldn't have access to?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
val = numpy.ascontiguousarray( | |
[ | |
[ | |
[[4, 8, 15], [16, 23, 42], [4, 8, 15], [16, 23, 42], [4, 8, 15]], | |
[[4, 8, 15], [16, 23, 42], [4, 8, 15], [16, 23, 42], [4, 8, 15]], | |
[[4, 8, 15], [16, 23, 42], [4, 8, 15], [16, 23, 42], [4, 8, 15]], | |
[[4, 8, 15], [16, 23, 42], [4, 8, 15], [16, 23, 42], [4, 8, 15]], | |
[[4, 8, 15], [16, 23, 42], [4, 8, 15], [16, 23, 42], [4, 8, 15]], | |
] | |
], | |
dtype="uint8", | |
) | |
frame = numpy.ndarray((int(5), int(5), 3), dtype="uint8", buffer=val) | |
data = bytes(frame) | |
del frame | |
del val | |
frame2 = numpy.ndarray((int(5), int(5), 3), dtype="uint8", buffer=data) | |
frame3 = numpy.ndarray((int(5), int(5), 3), dtype="uint8") | |
assert numpy.array_equal(frame2, frame3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tested with
Python 3.8.1
andnumpy==1.18.1
on MacOS Mojave 10.14.5.Assert is not triggered.