From c4efab61cdccb229d92e99309f672bf756445fdb Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Tue, 7 May 2019 16:11:49 -0500 Subject: [PATCH] Ensure that `pypdfChr()` always returns a `str` object Fixes #42 --- pypdf/utils.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pypdf/utils.py b/pypdf/utils.py index f3ecfb9dc..e438776bf 100644 --- a/pypdf/utils.py +++ b/pypdf/utils.py @@ -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):