Skip to content

Commit

Permalink
PI: Remove ord_ calls (#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma committed Jun 19, 2022
1 parent 56158e0 commit 4c9fd44
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions PyPDF2/generic.py
Expand Up @@ -54,7 +54,6 @@
deprecate_with_replacement,
hex_str,
hexencode,
ord_,
read_non_whitespace,
read_until_regex,
skip_over_comment,
Expand Down Expand Up @@ -566,7 +565,7 @@ def write_to_stream(
stream.write(b"(")
for c in bytearr:
if not chr(c).isalnum() and c != b" ":
stream.write(b_(rf"\{ord_(c):0>3o}"))
stream.write(b_(rf"\{c:0>3o}"))
else:
stream.write(b_(chr(c)))
stream.write(b")")
Expand Down Expand Up @@ -1161,10 +1160,10 @@ def __parse_content_stream(self, stream: StreamType) -> None:
operands: List[Union[int, str, PdfObject]] = []
while True:
peek = read_non_whitespace(stream)
if peek == b"" or ord_(peek) == 0:
if peek == b"" or peek == 0:
break
stream.seek(-1, 1)
if peek.isalpha() or peek == b"'" or peek == b'"':
if peek.isalpha() or peek in (b"'", b'"'):
operator = read_until_regex(stream, NameObject.delimiter_pattern, True)
if operator == b"BI":
# begin inline image - a completely different parsing
Expand Down Expand Up @@ -1997,7 +1996,7 @@ def encode_pdfdocencoding(unicode_string: str) -> bytes:
def decode_pdfdocencoding(byte_array: bytes) -> str:
retval = ""
for b in byte_array:
c = _pdfdoc_encoding[ord_(b)]
c = _pdfdoc_encoding[b]
if c == "\u0000":
raise UnicodeDecodeError(
"pdfdocencoding",
Expand Down

0 comments on commit 4c9fd44

Please sign in to comment.