Skip to content

Commit a223e5f

Browse files
committed
Fix Python 3 exception errors.
1 parent ec7b3e2 commit a223e5f

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

stm32/support/hex2dfu.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def load_hex():
3939
else:
4040
ih.loadbin(args.source, args.start_addr)
4141

42-
except Exception, e:
42+
except Exception as e:
4343
print(e)
4444
exit(1)
4545

@@ -118,7 +118,7 @@ def save_dfu(ih):
118118
try:
119119
open(args.target, "wb").write(data)
120120

121-
except Exception, e:
121+
except Exception as e:
122122
print(e)
123123
exit(1)
124124

stm32/support/intelhex/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ def hex2bin(fin, fout, start=None, end=None, size=None, pad=None):
963963
"""
964964
try:
965965
h = IntelHex(fin)
966-
except HexReaderError, e:
966+
except HexReaderError as e:
967967
txt = "ERROR: bad HEX file: %s" % str(e)
968968
print(txt)
969969
return 1
@@ -985,7 +985,7 @@ def hex2bin(fin, fout, start=None, end=None, size=None, pad=None):
985985
# using .padding attribute rather than pad argument to function call
986986
h.padding = pad
987987
h.tobinfile(fout, start, end)
988-
except IOError, e:
988+
except IOError as e:
989989
txt = "ERROR: Could not write to file: %s: %s" % (fout, str(e))
990990
print(txt)
991991
return 1
@@ -1005,14 +1005,14 @@ def bin2hex(fin, fout, offset=0):
10051005
h = IntelHex()
10061006
try:
10071007
h.loadbin(fin, offset)
1008-
except IOError, e:
1008+
except IOError as e:
10091009
txt = 'ERROR: unable to load bin file:', str(e)
10101010
print(txt)
10111011
return 1
10121012

10131013
try:
10141014
h.tofile(fout, format='hex')
1015-
except IOError, e:
1015+
except IOError as e:
10161016
txt = "ERROR: Could not write to file: %s: %s" % (fout, str(e))
10171017
print(txt)
10181018
return 1

stm32/support/intelhex/bench.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def main(argv=None):
258258

259259
if args:
260260
raise getopt.GetoptError('Arguments are not used.')
261-
except getopt.GetoptError, msg:
261+
except getopt.GetoptError as msg:
262262
txt = str(msg)
263263
print(txt)
264264
return 1

stm32/support/intelhex/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def assertRaisesMsg(self, excClass, msg, callableObj, *args, **kwargs):
376376
"""
377377
try:
378378
callableObj(*args, **kwargs)
379-
except excClass, exc:
379+
except excClass as exc:
380380
excMsg = str(exc)
381381
if not msg:
382382
# No message provided: any message is fine.

0 commit comments

Comments
 (0)