Skip to content

Commit 0381b30

Browse files
authored
Fix the pylint, add in one other I've been using
1 parent ac1cb99 commit 0381b30

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

adafruit_pioasm.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ def assemble(text_program):
105105
if len(instruction) > 2:
106106
try:
107107
assembled[-1] |= CONDITIONS.index(instruction[1]) << 5
108-
except ValueError:
109-
raise SyntaxError(f"Invalid jmp condition {instruction[1]}")
108+
except ValueError as exc:
109+
raise SyntaxError(f"Invalid jmp condition {instruction[1]}") from exc
110110

111111
elif instruction[0] == "wait":
112112
# instr delay p sr index
@@ -154,7 +154,10 @@ def assemble(text_program):
154154
source = instruction[-1]
155155
source_split = mov_splitter(source)
156156
if len(source_split) == 1:
157-
assembled[-1] |= MOV_SOURCES.index(source)
157+
try:
158+
assembled[-1] |= MOV_SOURCES.index(source)
159+
except ValueError as exc:
160+
raise RuntimeError("Invalid mov source:", source) from exc
158161
else:
159162
assembled[-1] |= MOV_SOURCES.index(source_split[1])
160163
if source[:1] == "!":
@@ -188,8 +191,8 @@ def assemble(text_program):
188191
assembled.append(0b111_00000_000_00000)
189192
try:
190193
assembled[-1] |= SET_DESTINATIONS.index(instruction[1]) << 5
191-
except ValueError:
192-
raise RuntimeError(f"Uknnown set destination {instruction[1]}")
194+
except ValueError as exc:
195+
raise RuntimeError(f"Uknnown set destination {instruction[1]}") from exc
193196
value = int(instruction[-1])
194197
if not 0 <= value <= 31:
195198
raise RuntimeError("Set value out of range")

0 commit comments

Comments
 (0)