[issue29159] Regression in bytes constructor

2018-10-14 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- pull_requests: -1003 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue29159] Regression in bytes constructor

2017-03-31 Thread Donald Stufft
Changes by Donald Stufft : -- pull_requests: +1003 ___ Python tracker ___ ___

[issue29159] Regression in bytes constructor

2017-01-06 Thread INADA Naoki
INADA Naoki added the comment: > patch LGTM except that arguments of assertEqual are in reversed order. fixed. -- resolution: -> fixed stage: -> resolved status: open -> closed ___ Python tracker

[issue29159] Regression in bytes constructor

2017-01-06 Thread Roundup Robot
Roundup Robot added the comment: New changeset 505cc50ddc82 by INADA Naoki in branch '3.6': Issue #29159: Fix regression in bytes(x) when x.__index__() raises Exception. https://hg.python.org/cpython/rev/505cc50ddc82 -- nosy: +python-dev ___ Python

[issue29159] Regression in bytes constructor

2017-01-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The code restored by 29159-index-fallback.patch is slightly different from the code before issue27704, but the patch LGTM except that arguments of assertEqual are in reversed order. > Can you explain what your patch does? I don't understand why you single

[issue29159] Regression in bytes constructor

2017-01-05 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On the other hand, the documentation for the bytearray constructor [1] lists integer argument first. [1]: https://docs.python.org/3/library/functions.html#bytearray -- ___ Python tracker

[issue29159] Regression in bytes constructor

2017-01-05 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: @inada.naoki Sorry, I still don't understand the role of OverflowError. With respect to my earlier suggestion that buffer protocol should have priority over __index__, note that the documentation implies the same order: >>> help(bytes) class

[issue29159] Regression in bytes constructor

2017-01-04 Thread INADA Naoki
INADA Naoki added the comment: @belopolsky It is backported behavior from Python 3.5, to fix regression. See code review discussion in #27704. The first patch kept the behavior, but we simplified it in second patch. That cause this regression. --

[issue29159] Regression in bytes constructor

2017-01-04 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Inada, Can you explain what your patch does? I don't understand why you single out the OverflowError. When is __index__ expected to raise it? >>> (2**300).__index__()

[issue29159] Regression in bytes constructor

2017-01-04 Thread INADA Naoki
Changes by INADA Naoki : -- keywords: +patch Added file: http://bugs.python.org/file46147/29159-index-fallback.patch ___ Python tracker

[issue29159] Regression in bytes constructor

2017-01-04 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Also relevant: * #20895 - Add bytes.empty_buffer and deprecate bytes(17) for the same purpose * PEP 467 - Minor API improvements for binary sequences -- ___ Python tracker

[issue29159] Regression in bytes constructor

2017-01-04 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- nosy: +ncoghlan ___ Python tracker ___

[issue29159] Regression in bytes constructor

2017-01-04 Thread Alexander Belopolsky
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

[issue29159] Regression in bytes constructor

2017-01-04 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Ah, if numpy arrays are affected, this should be restored. But swallowing an arbitrary exception doesn't look good to me. -- ___ Python tracker

[issue29159] Regression in bytes constructor

2017-01-04 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +inada.naoki ___ Python tracker ___ ___

[issue29159] Regression in bytes constructor

2017-01-04 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Indeed, there is behavior change. It is easy to revert the old behavior. But was the old behavior designed? It looks as a side effect of the implementation. What is a reason of making an array an integer type? --

[issue29159] Regression in bytes constructor

2017-01-04 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: My test code may seem contrived, but numpy arrays exhibit similar behavior: >>> a = numpy.array([2, 2]) >>> bytes(a) Traceback (most recent call last): File "", line 1, in TypeError: only integer arrays with one element can be converted to an index

[issue29159] Regression in bytes constructor

2017-01-04 Thread Alexander Belopolsky
New submission from Alexander Belopolsky: Consider the following code: $ cat bug.py from array import array class C(array): def __new__(cls): return array.__new__(cls, 'B', b'abc') def __index__(self): raise TypeError x = C() print(bytes(x)) It works under python 3.5: