issue #2959: another Py2 bugfix

This commit is contained in:
Dvořák Václav 2018-01-26 16:12:39 +01:00
parent 524addc499
commit 971837cc00

View File

@ -294,7 +294,7 @@ def pdf_repr(x):
return bytes(PdfDict(x))
elif isinstance(x, list):
return bytes(PdfArray(x))
elif isinstance(x, str) and str != bytes:
elif (str == bytes and isinstance(x, unicode)) or (str != bytes and isinstance(x, str)):
return pdf_repr(encode_text(x))
elif isinstance(x, bytes):
return b"(" + x.replace(b"\\", b"\\\\").replace(b"(", b"\\(").replace(b")", b"\\)") + b")" # XXX escape more chars? handle binary garbage