Alexander Belopolsky added the comment: 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>. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29159> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com