Skip to content

Commit

Permalink
tests: Use Python 2.6 "except E as ..." syntax
Browse files Browse the repository at this point in the history
PEP 8 calls for it, because it's forward compatible with Python 3.
Supported since Python 2.6, which we require (commit fec2103).

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <1450425164-24969-5-git-send-email-armbru@redhat.com>
  • Loading branch information
Markus Armbruster committed Feb 8, 2016
1 parent 86b227d commit 03e1881
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions tests/image-fuzzer/runner.py
Expand Up @@ -157,7 +157,7 @@ def __init__(self, test_id, seed, work_dir, run_log,

try:
os.makedirs(self.current_dir)
except OSError, e:
except OSError as e:
print >>sys.stderr, \
"Error: The working directory '%s' cannot be used. Reason: %s"\
% (self.work_dir, e[1])
Expand Down Expand Up @@ -244,7 +244,7 @@ def execute(self, input_commands=None, fuzz_config=None):
temp_log = StringIO.StringIO()
try:
retcode = run_app(temp_log, current_cmd)
except OSError, e:
except OSError as e:
multilog("%sError: Start of '%s' failed. Reason: %s\n\n"
% (test_summary, os.path.basename(current_cmd[0]),
e[1]),
Expand Down Expand Up @@ -356,7 +356,7 @@ def should_continue(duration, start_time):
opts, args = getopt.gnu_getopt(sys.argv[1:], 'c:hs:kvd:',
['command=', 'help', 'seed=', 'config=',
'keep_passed', 'verbose', 'duration='])
except getopt.error, e:
except getopt.error as e:
print >>sys.stderr, \
"Error: %s\n\nTry 'runner.py --help' for more information" % e
sys.exit(1)
Expand All @@ -374,7 +374,7 @@ def should_continue(duration, start_time):
elif opt in ('-c', '--command'):
try:
command = json.loads(arg)
except (TypeError, ValueError, NameError), e:
except (TypeError, ValueError, NameError) as e:
print >>sys.stderr, \
"Error: JSON array of test commands cannot be loaded.\n" \
"Reason: %s" % e
Expand All @@ -390,7 +390,7 @@ def should_continue(duration, start_time):
elif opt == '--config':
try:
config = json.loads(arg)
except (TypeError, ValueError, NameError), e:
except (TypeError, ValueError, NameError) as e:
print >>sys.stderr, \
"Error: JSON array with the fuzzer configuration cannot" \
" be loaded\nReason: %s" % e
Expand All @@ -414,7 +414,7 @@ def should_continue(duration, start_time):

try:
image_generator = __import__(generator_name)
except ImportError, e:
except ImportError as e:
print >>sys.stderr, \
"Error: The image generator '%s' cannot be imported.\n" \
"Reason: %s" % (generator_name, e)
Expand Down
2 changes: 1 addition & 1 deletion tests/qemu-iotests/qed.py
Expand Up @@ -227,7 +227,7 @@ def main():
qed = QED(open(filename, 'r+b'))
try:
globals()[cmd](qed, *sys.argv[3:])
except TypeError, e:
except TypeError as e:
sys.stderr.write(globals()[cmd].__doc__ + '\n')
sys.exit(1)

Expand Down

0 comments on commit 03e1881

Please sign in to comment.