Fix bytes/unicode detection
https://github.com/behdad/fonttools/pull/233
This commit is contained in:
parent
73031d5a63
commit
034ed355de
@ -25,11 +25,14 @@ class XMLWriter(object):
|
|||||||
|
|
||||||
# Figure out if writer expects bytes or unicodes
|
# Figure out if writer expects bytes or unicodes
|
||||||
try:
|
try:
|
||||||
self.file.write(tounicode(''))
|
# The bytes check should be first. See:
|
||||||
self.totype = tounicode
|
# https://github.com/behdad/fonttools/pull/233
|
||||||
except TypeError:
|
|
||||||
self.file.write(b'')
|
self.file.write(b'')
|
||||||
self.totype = tobytes
|
self.totype = tobytes
|
||||||
|
except TypeError:
|
||||||
|
# This better not fail.
|
||||||
|
self.file.write(tounicode(''))
|
||||||
|
self.totype = tounicode
|
||||||
self.indentwhite = self.totype(indentwhite)
|
self.indentwhite = self.totype(indentwhite)
|
||||||
self.newlinestr = self.totype('\n')
|
self.newlinestr = self.totype('\n')
|
||||||
self.indentlevel = 0
|
self.indentlevel = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user