Skip to content

Commit

Permalink
Ensure that pypdfChr() always returns a str object
Browse files Browse the repository at this point in the history
Fixes py-pdf#42
  • Loading branch information
kurtmckee committed May 7, 2019
1 parent 944c4d7 commit c4efab6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pypdf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,12 @@ def pypdfOrd(b):

def pypdfChr(c):
"""
Abstracts the conversion from a single byte to the corresponding ASCII
character over versions 2.7.x and 3 of Python.
:type c: Union[int, bytes, str, unicode]
:rtype: str
"""
if sys.version_info[0] < 3:
return c
else:
if isinstance(c, int):
return chr(c)
return chr(ord(c))


def pypdfBytearray(b):
Expand Down

0 comments on commit c4efab6

Please sign in to comment.