From 74ed1cd233db9bb24aecedcbdf66bc66a5c905f9 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 26 Jan 2015 19:02:57 +0100 Subject: Remove a superfluous try/except block --- monkey/monkey.py | 11 ++++------- monkey/prolog/engine.py | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'monkey') diff --git a/monkey/monkey.py b/monkey/monkey.py index 8faad1a..5d26c6e 100755 --- a/monkey/monkey.py +++ b/monkey/monkey.py @@ -63,15 +63,12 @@ def fix(name, code, edits, aux_code='', timeout=30, debug=False): for line, (before, after) in path: print('line ' + str(line) + ':\t' + stringify(before) + ' → ' + stringify(after)) - # if the code is correct, we are done - try: - if test(name, code + '\n' + aux_code): - return code, path, total_time, n_tested - except: - pass + # If the code is correct, we are done. + if test(name, code + '\n' + aux_code): + return code, path, total_time, n_tested n_tested += 1 - # otherwise generate new solutions + # Otherwise generate new solutions. rule_no = 0 for start, end in rules: rule = lines[start:end] diff --git a/monkey/prolog/engine.py b/monkey/prolog/engine.py index 5a640c0..af79535 100644 --- a/monkey/prolog/engine.py +++ b/monkey/prolog/engine.py @@ -124,7 +124,7 @@ def test(name, code): reply = create_and_ask(code=code, query='run_tests({})'.format(name)) return reply['event'] == 'success' except Exception as ex: - pass + return False # Basic sanity check. if __name__ == '__main__': -- cgit v1.2.1