diff --git a/pypdf/_codecs/__init__.py b/pypdf/_codecs/__init__.py index 3693a5a87b..06e210ae42 100644 --- a/pypdf/_codecs/__init__.py +++ b/pypdf/_codecs/__init__.py @@ -10,7 +10,7 @@ def fill_from_encoding(enc: str) -> list[str]: for x in range(256): try: lst += (bytes((x,)).decode(enc),) - except Exception: + except UnicodeDecodeError: lst += (chr(x),) return lst