Skip to content

Commit

Permalink
py2 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
staffanm committed Dec 5, 2017
1 parent 66f4902 commit 9efaeb2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ferenda/pdfreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,10 @@ def txt(element_text):
if not isinstance(buffer, bytes):
self.log.warning("File %s was opened in text, not binary mode" % util.name_from_fp(xmlfp))
buffer = bytes(buffer.encode("utf-8"))
else:
# convert to a py3 style bytes() object (one that
# returns ints, not strs, when iterating over it)
buffer = bytes(buffer)
for b in buffer:
# leave some control chars as-is (CR/LF but not TAB)
if b < 0x20 and b not in (0xa, 0xd):
Expand Down

0 comments on commit 9efaeb2

Please sign in to comment.