Created on 2016-12-17 13:41 by woo yoo, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Pull Requests |
|
|
|
URL |
Status |
Linked |
Edit |
PR 552 |
closed |
dstufft,2017-03-31 16:36 |
|
Messages (9) |
|
|
msg283485 - (view) |
Author: woo yoo (woo yoo) |
Date: 2016-12-17 13:41 |
Per the documentation,"The alternate form causes a leading octal specifier ('0o') to be inserted before the first digit", However the actual behavior didn't conform to the principle. Code: >>>b'%#07o' % 34 Output: b'0000o42' |
|
|
msg283486 - (view) |
Author: woo yoo (woo yoo) |
Date: 2016-12-17 13:41 |
The link is https://docs.python.org/3.5/library/stdtypes.html#printf-style-bytes-formatting |
|
|
msg283488 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2016-12-17 14:29 |
The documentation matches the behavior. In this context "the first digit" is the 4. The leading zeros are the pad fill. Now, whether this is *useful* behavior or not is a separate question :) And yes, the docs could be clarified on this point either way. |
|
|
msg283489 - (view) |
Author: woo yoo (woo yoo) |
Date: 2016-12-17 14:37 |
Make a slight change to my code, which becomes `b'%#07x' % 34`, the weird situation appears. |
|
|
msg283491 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2016-12-17 15:18 |
This is not documentation issue, but a bug in formatting octals in bytes. >>> '%#07x' % 123 '0x0007b' >>> b'%#07x' % 123 b'0x0007b' >>> '%#07o' % 123 '0o00173' >>> b'%#07o' % 123 b'000o173' ^ |
|
|
msg283499 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2016-12-17 16:27 |
Proposed patch fixes this inconsistency. |
|
|
msg283502 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2016-12-17 18:06 |
OK, that makes sense. Patch looks good to me. |
|
|
msg283513 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2016-12-17 20:16 |
New changeset 96d728c14267 by Serhiy Storchaka in branch '3.5': Issue #29000: Fixed bytes formatting of octals with zero padding in alternate https://hg.python.org/cpython/rev/96d728c14267 New changeset 29c9c414c310 by Serhiy Storchaka in branch '3.6': Issue #29000: Fixed bytes formatting of octals with zero padding in alternate https://hg.python.org/cpython/rev/29c9c414c310 New changeset 4e55e011dd80 by Serhiy Storchaka in branch 'default': Issue #29000: Fixed bytes formatting of octals with zero padding in alternate https://hg.python.org/cpython/rev/4e55e011dd80 |
|
|
msg283514 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2016-12-17 20:18 |
Thanks David. |
|
|
History |
|
|
|
Date |
User |
Action |
Args |
2022-04-11 14:58:40 |
admin |
set |
github: 73186 |
2017-03-31 16:36:28 |
dstufft |
set |
pull_requests: + <pull%5Frequest1017> |
2016-12-17 20🔞12 |
serhiy.storchaka |
set |
status: open -> closedmessages: + assignee: docs@python -> serhiy.storchakaresolution: fixedstage: patch review -> resolved |
2016-12-17 20:16:48 |
python-dev |
set |
nosy: + python-devmessages: + |
2016-12-17 18:06:35 |
r.david.murray |
set |
messages: + |
2016-12-17 16:27:23 |
serhiy.storchaka |
set |
files: + bytes-format-oct-alt-zero.patchkeywords: + patchmessages: + stage: needs patch -> patch review |
2016-12-17 15🔞22 |
serhiy.storchaka |
set |
type: behaviorcomponents: + Interpreter Core, - Documentationversions: + Python 3.6, Python 3.7nosy: + serhiy.storchaka, ethan.furmanmessages: + stage: needs patch |
2016-12-17 14:37:49 |
woo yoo |
set |
messages: + |
2016-12-17 14:29:46 |
r.david.murray |
set |
nosy: + r.david.murraymessages: + |
2016-12-17 13:41:41 |
woo yoo |
set |
messages: + |
2016-12-17 13:41:04 |
woo yoo |
create |
|