On 7 June 2016 at 21:56, Nick Coghlan email@example.com wrote:
On 7 June 2016 at 14:33, Paul Sokolovsky firstname.lastname@example.org wrote:
Ethan Furman email@example.com wrote:
Deprecation of current "zero-initialised sequence" behaviour
Currently, the ``bytes`` and ``bytearray`` constructors accept an integer argument and interpret it as meaning to create a zero-initialised sequence of the given size::
>>> bytes(3) b'\x00\x00\x00' >>> bytearray(3) bytearray(b'\x00\x00\x00')
This PEP proposes to deprecate that behaviour in Python 3.6, and remove it entirely in Python 3.7.
Why the desire to break applications of thousands and thousands of people?
Same argument as any deprecation: to make existing and future defects easier to find or easier to debug.
That said, this is the main part I was referring to in the other thread when I mentioned some of the constructor changes were potentially controversial and probably not worth the hassle - it's the only one with the potential to break currently working code, while the others are just a matter of choosing suitable names.
An argument against deprecating bytearray(n) in particular is that this is supported in Python 2. I think I have (ab)used this fact to work around the problem with bytes(n) in Python 2 & 3 compatible code.