You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
x format of % operator broken in Python 3.5.2 #71859
Note: 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:
assignee=Noneclosed_at=<Date2016-08-03.11:51:03.417>created_at=<Date2016-08-03.11:18:43.632>labels= ['interpreter-core', 'type-bug']
title='x format of % operator broken in Python 3.5.2'updated_at=<Date2016-09-09.18:35:41.191>user='https://bugs.python.org/PeterTom'
In Python 3.4.4 (64-bit) and in many previous versions it worked like this:
>>> "%02x"%12.99
'0c'
Now in Python 3.5.2 (64-bit) it shows an error:
>>> "%02x"%12.99
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
"%02x" % 12.99
TypeError: %x format: an integer is required, not float
This problem broke some of my code which uses turtle.py (which is part of the cpython distribution), but I can see similar problems also in some third party code (e.g. I can see it in canvasvg3.py).
So I kindly ask for returning the 3.4-like interpretation of the x format (and o format and maybe also other formats).
So it is even worse, it is an "intentional break".
I will need to review a few thousands lines of code because of this.
I think that breaking others' code by redefining a "built-in" operator is acceptable when changing major versions (like 2 to 3), not minor ones (3.4 to 3.5).
I'm not suggesting your reviewing code, I've referenced issue where this change was discussed and implemented so that you can familiarize yourself with the arguments. Your code worked by accident, the workaround seems trivial.
If you wish to advance further arguments, please take them to that issue. This issue is closed and doesn't need re-opening.
Activity
PeterTom commentedon Aug 3, 2016
In Python 3.4.4 (64-bit) and in many previous versions it worked like this:
This problem broke some of my code which uses turtle.py (which is part of the cpython distribution), but I can see similar problems also in some third party code (e.g. I can see it in canvasvg3.py).
So I kindly ask for returning the 3.4-like interpretation of the x format (and o format and maybe also other formats).
SilentGhost commentedon Aug 3, 2016
It's not an accidental change (so it's not "broken" by any definition), see bpo-19995 for details.
PeterTom commentedon Aug 3, 2016
So it is even worse, it is an "intentional break".
I will need to review a few thousands lines of code because of this.
I think that breaking others' code by redefining a "built-in" operator is acceptable when changing major versions (like 2 to 3), not minor ones (3.4 to 3.5).
SilentGhost commentedon Aug 3, 2016
I'm not suggesting your reviewing code, I've referenced issue where this change was discussed and implemented so that you can familiarize yourself with the arguments. Your code worked by accident, the workaround seems trivial.
If you wish to advance further arguments, please take them to that issue. This issue is closed and doesn't need re-opening.
ethanfurman commentedon Aug 3, 2016
I'm not trying to rub salt in the wound, but it's a good idea (for all of us) to test our programs with "-W always" to see if any thing pops up:
$ python3.4 -W always -c "'%x' % 3.14" sys:1: DeprecationWarning: automatic int conversions have been deprecatedAlso, this change was made because it was considered a bug.
[-]x fromat of % operator broken in Python 3.5.2[/-][+]x format of % operator broken in Python 3.5.2[/+]