Skip to content

Commit a1a1e95

Browse files
committed
fix: replace except: with except Exception: (by haosenwang1018@github)
Remove bare 'except:' statements replace with 'except Exception'. In roundup_xmlrpc_server.py I changed Exception to BaseException so the database gets closed on signals as well. The rest of the changes do not look like they affect data integrity and are commited as supplied.
1 parent b6cf1c5 commit a1a1e95

File tree

18 files changed

+25
-23
lines changed

18 files changed

+25
-23
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ Fixed:
4545
into Client(). (John Rouillard)
4646
- issue2551393 - Named searches lose their name in title when next
4747
page is selected. (John Rouillard)
48+
- code cleanup replace bare except: with except Exception:. (patch by
49+
Sense_wang (haosenwang1018) applied by John Rouillard)
4850

4951
Features:
5052

frontends/ZRoundup/ZRoundup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def index_html(self, REQUEST=None):
210210
except client.NotFound:
211211
raise Exception('NotFound ' + REQUEST.URL)
212212
pass
213-
except:
213+
except Exception:
214214
import traceback
215215
traceback.print_exc()
216216
# all other exceptions in roundup are valid

roundup/anypy/vendored/cgi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ def g(f=f):
870870
f()
871871
print("<H3>What follows is a test, not an actual exception:</H3>")
872872
g()
873-
except:
873+
except Exception:
874874
print_exception()
875875

876876
print("<H1>Second try with a small maxlen...</H1>")
@@ -883,7 +883,7 @@ def g(f=f):
883883
print_arguments()
884884
print_form(form)
885885
print_environ(environ)
886-
except:
886+
except Exception:
887887
print_exception()
888888

889889
def print_exception(type=None, value=None, tb=None, limit=None):

roundup/backends/rdbms_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2612,7 +2612,7 @@ def collect_values(n):
26122612
e.context['class'] = pln
26132613
e.context['attr'] = prp
26142614
raise
2615-
except:
2615+
except Exception:
26162616
pass
26172617
# Fallback to original code
26182618
args = []
@@ -2693,7 +2693,7 @@ def collect_values(n):
26932693
e.context['class'] = classname
26942694
e.context['attr'] = proptree.name
26952695
raise
2696-
except:
2696+
except Exception:
26972697
# fallback behavior when expression parsing above fails
26982698
orclause = ''
26992699
if '-1' in v:

roundup/cgi/PageTemplates/PageTemplate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def pt_errors(self):
106106
if not self.expand: return
107107
try:
108108
self.pt_render(source=1)
109-
except:
109+
except Exception:
110110
return ('Macro expansion failed', '%s: %s' % sys.exc_info()[:2])
111111

112112
def pt_warnings(self):
@@ -147,7 +147,7 @@ def read(self):
147147
return self._text
148148
try:
149149
return self.pt_render(source=1)
150-
except:
150+
except Exception:
151151
return ('%s\n Macro expansion failed\n %s\n-->\n%s' %
152152
(self._error_start, "%s: %s" % sys.exc_info()[:2],
153153
self._text) )
@@ -177,7 +177,7 @@ def _cook(self):
177177
try:
178178
parser.parseString(self._text)
179179
self._v_program, self._v_macros = parser.getCode()
180-
except:
180+
except Exception:
181181
self._v_errors = ["Compilation failed",
182182
"%s: %s" % sys.exc_info()[:2]]
183183
self._v_warnings = parser.getWarnings()

roundup/cgi/PageTemplates/PythonExpr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(self, name, expr, engine):
3636
self.f_code = 'def f():\n return %s\n' % expr.strip()
3737
exec(self.f_code, d)
3838
self._f = d['f']
39-
except:
39+
except Exception:
4040
raise CompilerError(('Python expression error:\n'
4141
'%s: %s') % exc_info()[:2])
4242
self._get_used_names()

roundup/cgi/TAL/DummyEngine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def evaluate(self, expression):
118118
if type == "python":
119119
try:
120120
return eval(expr, self.globals, self.locals)
121-
except:
121+
except Exception:
122122
raise TALESError("evaluation error in %s" % repr(expr))
123123
if type == "position":
124124
# Insert the current source file name, line number,

roundup/cgi/TAL/TALInterpreter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ def do_onError_tal(self, block_handler):
724724
self._stream_write = stream.write
725725
try:
726726
self.interpret(block)
727-
except:
727+
except Exception:
728728
exc = sys.exc_info()[1]
729729
self.restoreState(state)
730730
engine = self.engine

roundup/cgi/ZTUtils/Iterator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def _supports(self, ob):
189189
try:
190190
if hasattr(ob, 'next') and (ob is iter(ob)):
191191
return 1
192-
except:
192+
except Exception:
193193
return 0
194194

195195
def prep_next(self, it):

roundup/cgi/templating.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2717,7 +2717,7 @@ def __init__(self, *args, **kwargs):
27172717
# ignore these errors to preserve user input
27182718
try:
27192719
display_value.sort(key=keyfun)
2720-
except:
2720+
except Exception:
27212721
pass
27222722
self._value = display_value
27232723

0 commit comments

Comments
 (0)