Message284671
I don't think we should put too much effort into preserving numpy behavior. Consider this python 3.5 session:
>>> import numpy
>>> a = numpy.array([1])
>>> bytes(a)
__main__:1: VisibleDeprecationWarning: converting an array with ndim > 0 to an index will result in an error in the future
b'\x00'
>>> a = numpy.array([2, 2])
>>> bytes(a)
b'\x02\x00\x00\x00\x02\x00\x00\x00'
It looks like this behavior is just an artifact of ndarray providing both __index__ and buffer protocol and not something thought out by numpy developers.
I wonder if we could check for buffer protocol support before detecting an integer argument? I also recall a discussion of deprecating bytes(int) altogether. See <https://mail.python.org/pipermail/python-ideas/2014-March/027295.html>. |
|
Date |
User |
Action |
Args |
2017-01-04 21:38:21 | belopolsky | set | recipients:
+ belopolsky, methane, serhiy.storchaka |
2017-01-04 21:38:21 | belopolsky | set | messageid: <1483565901.8.0.806547644677.issue29159@psf.upfronthosting.co.za> |
2017-01-04 21:38:21 | belopolsky | link | issue29159 messages |
2017-01-04 21:38:21 | belopolsky | create | |
|