This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: The Extended Iterable Unpacking (PEP-3132) for byte strings doesn't match the specification
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, georg.brandl, marco.buttu, python-dev
Priority: normal Keywords:

Created on 2013-01-10 14:08 by marco.buttu, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg179545 - (view) Author: Marco Buttu (marco.buttu) * Date: 2013-01-10 14:08
The PEP 3132 said:
"""
... if seq is a slicable sequence, all the following assignments are equivalent if seq has at least three elements:

a, b, c = seq[0], seq[1:-1], seq[-1]
a, *b, c = seq
[a, *b, c] = seq
"""

But this doesn't happen for byte strings:

>>> seq = b'xyz'
>>> a, b, c = seq[0], seq[1:-1], seq[-1]
>>> a, b, c
(120, b'y', 122)
>>> a, *b, c = seq
>>> a, b, c
(120, [121], 122)

Tested on Python3.3 and Python3.2 (Linux Ubuntu 11.04)
msg179713 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-01-11 18:07
New changeset a0077c1d201d by Georg Brandl in branch 'default':
Closes #16916: clarify "slicing equivalent to extended unpacking" example: the latter always creates a list.
http://hg.python.org/peps/rev/a0077c1d201d
msg179714 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-01-11 18:08
Thanks for the report. This statement was actually false for almost all sequence types, except for those whose slicing returns a list.
History
Date User Action Args
2022-04-11 14:57:40adminsetgithub: 61120
2013-01-11 18:08:37georg.brandlsetnosy: + georg.brandl
messages: + msg179714
2013-01-11 18:07:32python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg179713

resolution: fixed
stage: resolved
2013-01-11 17:16:55eric.araujosetnosy: + eric.araujo
2013-01-10 14:08:15marco.buttucreate