From 7c2568c34132a64c052be52d9f7d732977447307 Mon Sep 17 00:00:00 2001 From: mapaba79 Date: Sun, 20 Sep 2026 22:41:24 -0300 Subject: [PATCH] Fix unreachable error check in to_entropy() --- src/mnemonic/mnemonic.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mnemonic/mnemonic.py b/src/mnemonic/mnemonic.py index caa4ffb..3fdb687 100644 --- a/src/mnemonic/mnemonic.py +++ b/src/mnemonic/mnemonic.py @@ -165,8 +165,9 @@ def to_entropy(self, words: list[str] | str) -> bytearray: wordindex = 0 for word in words: # Find the words index in the wordlist - ndx = self.wordlist.index(self.normalize_string(word)) - if ndx < 0: + try: + ndx = self.wordlist.index(self.normalize_string(word)) + except ValueError: raise LookupError('Unable to find "%s" in word list.' % word) # Set the next 11 bits to the value of the index. for ii in range(11):