From 335c25c0450b8164544677794b9a552f542ecce6 Mon Sep 17 00:00:00 2001 From: Gregory Mori Date: Mon, 9 Apr 2018 12:21:59 -0700 Subject: [PATCH] only check for bytes input to enc() in python3 In python2, isinstance("", bytes) is true, causing enc() to suppress any string input. This results in fontnames being lost when running pdf2txt.py in python2. As this check was not present in the original python2 version of pdfminer, restrict it to only check when running in python3. --- pdfminer/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdfminer/utils.py b/pdfminer/utils.py index 9cbcbb3..0e948c2 100644 --- a/pdfminer/utils.py +++ b/pdfminer/utils.py @@ -275,7 +275,7 @@ def decode_text(s): # enc def enc(x, codec='ascii'): """Encodes a string for SGML/XML/HTML""" - if isinstance(x, bytes): + if six.PY3 and isinstance(x, bytes): return '' x = x.replace('&', '&').replace('>', '>').replace('<', '<').replace('"', '"') if codec: