mirror of
https://github.com/mnaberez/py65.git
synced 2024-12-29 06:29:48 +00:00
Remove exception indexing
This commit is contained in:
parent
ee02520689
commit
455fb5da2d
@ -54,7 +54,7 @@ class Monitor(cmd.Cmd):
|
|||||||
longopts = ['help', 'mpu=', 'load=', 'rom=', 'goto=']
|
longopts = ['help', 'mpu=', 'load=', 'rom=', 'goto=']
|
||||||
options, args = getopt.getopt(argv[1:], shortopts, longopts)
|
options, args = getopt.getopt(argv[1:], shortopts, longopts)
|
||||||
except getopt.GetoptError as exc:
|
except getopt.GetoptError as exc:
|
||||||
self._output(str(exc))
|
self._output(exc.message)
|
||||||
self._usage()
|
self._usage()
|
||||||
self._exit(1)
|
self._exit(1)
|
||||||
|
|
||||||
@ -507,7 +507,7 @@ class Monitor(cmd.Cmd):
|
|||||||
intval &= self.byteMask
|
intval &= self.byteMask
|
||||||
setattr(self._mpu, register, intval)
|
setattr(self._mpu, register, intval)
|
||||||
except KeyError as exc:
|
except KeyError as exc:
|
||||||
self._output(exc[0])
|
self._output(exc.message)
|
||||||
|
|
||||||
def help_cd(self):
|
def help_cd(self):
|
||||||
self._output("cd <directory>")
|
self._output("cd <directory>")
|
||||||
@ -520,7 +520,8 @@ class Monitor(cmd.Cmd):
|
|||||||
try:
|
try:
|
||||||
os.chdir(args)
|
os.chdir(args)
|
||||||
except OSError as exc:
|
except OSError as exc:
|
||||||
msg = "Cannot change directory: [%d] %s" % (exc[0], exc[1])
|
msg = "Cannot change directory: [%d] %s" % (exc.errno,
|
||||||
|
exc.strerror)
|
||||||
self._output(msg)
|
self._output(msg)
|
||||||
self.do_pwd()
|
self.do_pwd()
|
||||||
|
|
||||||
@ -550,7 +551,7 @@ class Monitor(cmd.Cmd):
|
|||||||
bytes = f.read()
|
bytes = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
except (urllib2.URLError, urllib2.HTTPError) as exc:
|
except (urllib2.URLError, urllib2.HTTPError) as exc:
|
||||||
msg = "Cannot fetch remote file: %s" % str(exc)
|
msg = "Cannot fetch remote file: %s" % exc.message
|
||||||
self._output(msg)
|
self._output(msg)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@ -559,7 +560,7 @@ class Monitor(cmd.Cmd):
|
|||||||
bytes = f.read()
|
bytes = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
except (OSError, IOError) as exc:
|
except (OSError, IOError) as exc:
|
||||||
msg = "Cannot load file: [%d] %s" % (exc[0], exc[1])
|
msg = "Cannot load file: [%d] %s" % (exc.errno, exc.strerror)
|
||||||
self._output(msg)
|
self._output(msg)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -601,7 +602,7 @@ class Monitor(cmd.Cmd):
|
|||||||
f.write(chr((byte >> shift) & 0xff))
|
f.write(chr((byte >> shift) & 0xff))
|
||||||
f.close()
|
f.close()
|
||||||
except (OSError, IOError) as exc:
|
except (OSError, IOError) as exc:
|
||||||
msg = "Cannot save file: [%d] %s" % (exc[0], exc[1])
|
msg = "Cannot save file: [%d] %s" % (exc.errno, exc.strerror)
|
||||||
self._output(msg)
|
self._output(msg)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class AddressParserTests(unittest.TestCase):
|
|||||||
parser.number('bad_label')
|
parser.number('bad_label')
|
||||||
self.fail()
|
self.fail()
|
||||||
except KeyError as exc:
|
except KeyError as exc:
|
||||||
self.assertEqual('Label not found: bad_label', exc[0])
|
self.assertEqual('Label not found: bad_label', exc.message)
|
||||||
|
|
||||||
def test_number_label_hex_offset(self):
|
def test_number_label_hex_offset(self):
|
||||||
parser = AddressParser()
|
parser = AddressParser()
|
||||||
@ -96,7 +96,7 @@ class AddressParserTests(unittest.TestCase):
|
|||||||
parser.number('bad_label+3')
|
parser.number('bad_label+3')
|
||||||
self.fail()
|
self.fail()
|
||||||
except KeyError as exc:
|
except KeyError as exc:
|
||||||
self.assertEqual('Label not found: bad_label', exc[0])
|
self.assertEqual('Label not found: bad_label', exc.message)
|
||||||
|
|
||||||
def test_number_bad_label_syntax(self):
|
def test_number_bad_label_syntax(self):
|
||||||
parser = AddressParser()
|
parser = AddressParser()
|
||||||
@ -105,7 +105,7 @@ class AddressParserTests(unittest.TestCase):
|
|||||||
parser.number('#$foo')
|
parser.number('#$foo')
|
||||||
self.fail()
|
self.fail()
|
||||||
except KeyError as exc:
|
except KeyError as exc:
|
||||||
self.assertEqual('Label not found: #$foo', exc[0])
|
self.assertEqual('Label not found: #$foo', exc.message)
|
||||||
|
|
||||||
def test_number_constrains_address_at_zero_or_above(self):
|
def test_number_constrains_address_at_zero_or_above(self):
|
||||||
parser = AddressParser()
|
parser = AddressParser()
|
||||||
|
@ -31,7 +31,7 @@ class HexdumpLoaderTests(unittest.TestCase):
|
|||||||
self.fail()
|
self.fail()
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
msg = 'Start address was not found in data'
|
msg = 'Start address was not found in data'
|
||||||
self.assert_(exc[0].startswith('Start address'))
|
self.assert_(str(exc).startswith('Start address'))
|
||||||
|
|
||||||
def test_raises_when_start_address_is_invalid(self):
|
def test_raises_when_start_address_is_invalid(self):
|
||||||
text = 'oops: aa bb cc'
|
text = 'oops: aa bb cc'
|
||||||
@ -40,7 +40,7 @@ class HexdumpLoaderTests(unittest.TestCase):
|
|||||||
self.fail()
|
self.fail()
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
msg = 'Could not parse address: oops'
|
msg = 'Could not parse address: oops'
|
||||||
self.assertEqual(msg, exc[0])
|
self.assertEqual(msg, str(exc))
|
||||||
|
|
||||||
def test_raises_when_start_address_is_too_short(self):
|
def test_raises_when_start_address_is_too_short(self):
|
||||||
text = '01: aa bb cc'
|
text = '01: aa bb cc'
|
||||||
@ -49,7 +49,7 @@ class HexdumpLoaderTests(unittest.TestCase):
|
|||||||
self.fail()
|
self.fail()
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
msg = 'Expected address to be 2 bytes, got 1'
|
msg = 'Expected address to be 2 bytes, got 1'
|
||||||
self.assertEqual(msg, exc[0])
|
self.assertEqual(msg, str(exc))
|
||||||
|
|
||||||
def test_raises_when_start_address_is_too_long(self):
|
def test_raises_when_start_address_is_too_long(self):
|
||||||
text = '010304: aa bb cc'
|
text = '010304: aa bb cc'
|
||||||
@ -58,7 +58,7 @@ class HexdumpLoaderTests(unittest.TestCase):
|
|||||||
self.fail()
|
self.fail()
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
msg = 'Expected address to be 2 bytes, got 3'
|
msg = 'Expected address to be 2 bytes, got 3'
|
||||||
self.assertEqual(msg, exc[0])
|
self.assertEqual(msg, str(exc))
|
||||||
|
|
||||||
def test_raises_when_next_address_is_unexpected(self):
|
def test_raises_when_next_address_is_unexpected(self):
|
||||||
text = "c000: aa\nc002: cc"
|
text = "c000: aa\nc002: cc"
|
||||||
@ -68,7 +68,7 @@ class HexdumpLoaderTests(unittest.TestCase):
|
|||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
msg = 'Non-contigous block detected. Expected next ' \
|
msg = 'Non-contigous block detected. Expected next ' \
|
||||||
'address to be $c001, label was $c002'
|
'address to be $c001, label was $c002'
|
||||||
self.assertEqual(msg, exc[0])
|
self.assertEqual(msg, str(exc))
|
||||||
|
|
||||||
def test_raises_when_data_is_invalid(self):
|
def test_raises_when_data_is_invalid(self):
|
||||||
text = 'c000: foo'
|
text = 'c000: foo'
|
||||||
@ -77,7 +77,7 @@ class HexdumpLoaderTests(unittest.TestCase):
|
|||||||
self.fail()
|
self.fail()
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
msg = 'Could not parse data: foo'
|
msg = 'Could not parse data: foo'
|
||||||
self.assertEqual(msg, exc[0])
|
self.assertEqual(msg, str(exc))
|
||||||
|
|
||||||
def test_loads_data_without_dollar_signs(self):
|
def test_loads_data_without_dollar_signs(self):
|
||||||
text = 'c000: aa bb'
|
text = 'c000: aa bb'
|
||||||
|
Loading…
Reference in New Issue
Block a user