glance client http.py string format error
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Glance Client |
Fix Released
|
Undecided
|
Le Tian Ren |
Bug Description
Issue:
Found this coding defect when we ran into "TypeError: not all arguments converted during string formatting"
https:/
msg = 'Unable to load CA from "%s"' % (self.cacert, e)
proposed fix is
msg = 'Unable to load CA from "%s" due to %s' % (self.cacert, e)
or use
msg = 'Unable to load CA from "{0}" due to {1}'.format(
or if the original author intend to use tuple to format the msg
msg = 'Unable to load CA from "%s"' % ((self.cacert, e),)
I prefer the 2nd one, .format one.
(Edited in 2014/01/06)
I'll make L438 align with L431, L416, although it is not my first choice to format string.
BTW, during fixing this bug, I found that pep8 and flake8 won't report such string
format error, but pylint can
pylint http.py | grep "format string"
E:438,22:
So I suggest the community use editor with pylint integrated for static analysis.
Mine is vim + scrooloose/
Eclipse also has pylint plugin.
Changed in glance: | |
assignee: | nobody → Le Tian Ren (gpanda+) |
Changed in glance: | |
status: | New → Confirmed |
Changed in glance: | |
status: | Confirmed → In Progress |
tags: | added: low-hanging-fruit |
affects: | glance → python-glanceclient |
description: | updated |
description: | updated |
Changed in python-glanceclient: | |
status: | Fix Committed → Fix Released |
I think you should keep consistent on print out like in line 431