summaryrefslogtreecommitdiffstats
path: root/Lib/formatter.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-05-11 19:25:08 (GMT)
committerFred Drake <fdrake@acm.org>2001-05-11 19:25:08 (GMT)
commit6f6a14f888a80d97c846cd777a452c45acfc9fdc (patch)
tree56e49dc789cb071323488d3d404f3b8d5a9ef1a1 /Lib/formatter.py
parente8187615e281c409516b64eda5f7a5a56274e5a1 (diff)
downloadcpython-6f6a14f888a80d97c846cd777a452c45acfc9fdc.zip
cpython-6f6a14f888a80d97c846cd777a452c45acfc9fdc.tar.gz
cpython-6f6a14f888a80d97c846cd777a452c45acfc9fdc.tar.bz2
Remove a bare try/except completely -- it just did not make sense!
Add a comment elsewhere making clear an assumption in the code.
Diffstat (limited to 'Lib/formatter.py')
-rw-r--r--Lib/formatter.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/Lib/formatter.py b/Lib/formatter.py
index 8393e46..47e2e65 100644
--- a/Lib/formatter.py
+++ b/Lib/formatter.py
@@ -113,18 +113,15 @@ class AbstractFormatter:
def format_counter(self, format, counter):
label = ''
for c in format:
- try:
- if c == '1':
- label = label + ('%d' % counter)
- elif c in 'aA':
- if counter > 0:
- label = label + self.format_letter(c, counter)
- elif c in 'iI':
- if counter > 0:
- label = label + self.format_roman(c, counter)
- else:
- label = label + c
- except:
+ if c == '1':
+ label = label + ('%d' % counter)
+ elif c in 'aA':
+ if counter > 0:
+ label = label + self.format_letter(c, counter)
+ elif c in 'iI':
+ if counter > 0:
+ label = label + self.format_roman(c, counter)
+ else:
label = label + c
return label
@@ -132,6 +129,9 @@ class AbstractFormatter:
label = ''
while counter > 0:
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)
label = s + label
return label