New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not matched behavior within printf style bytes formatting #73186
Comments
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:
Output: b'0000o42' |
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. |
Make a slight change to my code, which becomes |
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'
^ |
Proposed patch fixes this inconsistency. |
OK, that makes sense. Patch looks good to me. |
New changeset 96d728c14267 by Serhiy Storchaka in branch '3.5': New changeset 29c9c414c310 by Serhiy Storchaka in branch '3.6': New changeset 4e55e011dd80 by Serhiy Storchaka in branch 'default': |
Thanks David. |
Misc/NEWS
so that it is managed by towncrier #552Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: