mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Remove a bare try/except completely -- it just did not make sense!
Add a comment elsewhere making clear an assumption in the code.
This commit is contained in:
parent
e8187615e2
commit
6f6a14f888
1 changed files with 12 additions and 12 deletions
|
@ -113,18 +113,15 @@ class AbstractFormatter:
|
||||||
def format_counter(self, format, counter):
|
def format_counter(self, format, counter):
|
||||||
label = ''
|
label = ''
|
||||||
for c in format:
|
for c in format:
|
||||||
try:
|
if c == '1':
|
||||||
if c == '1':
|
label = label + ('%d' % counter)
|
||||||
label = label + ('%d' % counter)
|
elif c in 'aA':
|
||||||
elif c in 'aA':
|
if counter > 0:
|
||||||
if counter > 0:
|
label = label + self.format_letter(c, counter)
|
||||||
label = label + self.format_letter(c, counter)
|
elif c in 'iI':
|
||||||
elif c in 'iI':
|
if counter > 0:
|
||||||
if counter > 0:
|
label = label + self.format_roman(c, counter)
|
||||||
label = label + self.format_roman(c, counter)
|
else:
|
||||||
else:
|
|
||||||
label = label + c
|
|
||||||
except:
|
|
||||||
label = label + c
|
label = label + c
|
||||||
return label
|
return label
|
||||||
|
|
||||||
|
@ -132,6 +129,9 @@ class AbstractFormatter:
|
||||||
label = ''
|
label = ''
|
||||||
while counter > 0:
|
while counter > 0:
|
||||||
counter, x = divmod(counter-1, 26)
|
counter, x = divmod(counter-1, 26)
|
||||||
|
# This makes a strong assumption that lowercase letters
|
||||||
|
# and uppercase letters form two contiguous blocks, with
|
||||||
|
# letters in order!
|
||||||
s = chr(ord(case) + x)
|
s = chr(ord(case) + x)
|
||||||
label = s + label
|
label = s + label
|
||||||
return label
|
return label
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue