bugfix: if fontname is bytes then skip (#43)

pull/55/head
Jin-tae Hwang 2016-12-15 01:34:16 +09:00 committed by Goulu
parent 6cc4abbaa8
commit 61d423d81c
1 changed files with 2 additions and 0 deletions

View File

@ -275,6 +275,8 @@ def decode_text(s):
# enc # enc
def enc(x, codec='ascii'): def enc(x, codec='ascii'):
"""Encodes a string for SGML/XML/HTML""" """Encodes a string for SGML/XML/HTML"""
if isinstance(x, bytes):
return ''
x = x.replace('&', '&amp;').replace('>', '&gt;').replace('<', '&lt;').replace('"', '&quot;') x = x.replace('&', '&amp;').replace('>', '&gt;').replace('<', '&lt;').replace('"', '&quot;')
if codec: if codec:
x = x.encode(codec, 'xmlcharrefreplace') x = x.encode(codec, 'xmlcharrefreplace')