Skip to content

Commit

Permalink
STY: Refactor b_ (py-pdf#2772)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-t-1 authored Aug 7, 2024
1 parent b2d7204 commit 5abd590
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pypdf/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,11 @@ def b_(s: Union[str, bytes]) -> bytes:
return bc[s]
try:
r = s.encode("latin-1")
if len(s) < 2:
bc[s] = r
return r
except Exception:
except UnicodeEncodeError:
r = s.encode("utf-8")
if len(s) < 2:
bc[s] = r
return r
if len(s) < 2:
bc[s] = r
return r


def str_(b: Any) -> str:
Expand Down

0 comments on commit 5abd590

Please sign in to comment.