1
0

crypto.pw_decode: fix one case of raising incorrect exception

This commit is contained in:
SomberNight
2020-04-08 12:49:50 +02:00
parent 789b78cab5
commit 1ea89af012
2 changed files with 9 additions and 1 deletions

View File

@@ -229,7 +229,10 @@ def pw_decode(data: str, password: Union[bytes, str, None], *, version: int) ->
if password is None:
return data
plaintext_bytes = pw_decode_bytes(data, password, version=version)
plaintext_str = to_string(plaintext_bytes, "utf8")
try:
plaintext_str = to_string(plaintext_bytes, "utf8")
except UnicodeDecodeError as e:
raise InvalidPassword() from e
return plaintext_str