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.
pull/139/head
Gregory Mori 2018-04-09 12:21:59 -07:00
parent eddf861fbd
commit 335c25c045
1 changed files with 1 additions and 1 deletions

View File

@ -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('&', '&amp;').replace('>', '&gt;').replace('<', '&lt;').replace('"', '&quot;')
if codec: