Skip to content

Commit 65914f8

Browse files
maresbWhyNotHugo
authored andcommitted
Be more explicit about the cases
1 parent a5917f1 commit 65914f8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

barcode/codex.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,14 @@ def _convert_or_buffer(self, char: str) -> int | None:
254254
return code128.C[char]
255255
if char.isdigit():
256256
self._buffer += char
257-
if len(self._buffer) == 2:
258-
value = int(self._buffer)
259-
self._buffer = ""
260-
return value
261-
return None
262-
raise RuntimeError(
263-
f"Character {char} could not be converted in charset {self._charset}."
264-
)
257+
if len(self._buffer) == 1:
258+
# Wait for the second digit to group in pairs
259+
return None
260+
assert len(self._buffer) == 2
261+
value = int(self._buffer)
262+
self._buffer = ""
263+
return value
264+
raise RuntimeError(f"Character {char} could not be converted in charset C.")
265265

266266
def _try_to_optimize(self, encoded: list[int]) -> list[int]:
267267
if encoded[1] in code128.TO:

0 commit comments

Comments
 (0)