userNameToFileName expects userName to be unicode strings, let it raise
if not
This commit is contained in:
parent
ec0fe57545
commit
bb21cb7c3a
@ -3,6 +3,7 @@ import shutil
|
||||
from io import StringIO, BytesIO, open
|
||||
import codecs
|
||||
from copy import deepcopy
|
||||
from fontTools.misc.py23 import basestring, unicode
|
||||
from ufoLib.glifLib import GlyphSet
|
||||
from ufoLib.validators import *
|
||||
from ufoLib.filenames import userNameToFileName
|
||||
@ -38,11 +39,6 @@ fontinfo.plist values between the possible format versions.
|
||||
convertFontInfoValueForAttributeFromVersion3ToVersion2
|
||||
"""
|
||||
|
||||
try:
|
||||
basestring
|
||||
except NameError:
|
||||
basestring = str
|
||||
|
||||
__all__ = [
|
||||
"makeUFOPath"
|
||||
"UFOLibError",
|
||||
@ -1066,9 +1062,9 @@ class UFOWriter(object):
|
||||
# not caching this could be slightly expensive,
|
||||
# but caching it will be cumbersome
|
||||
existing = [d.lower() for d in list(self.layerContents.values())]
|
||||
if not isinstance(layerName, basestring):
|
||||
if not isinstance(layerName, unicode):
|
||||
try:
|
||||
layerName = str(layerName)
|
||||
layerName = unicode(layerName)
|
||||
except UnicodeDecodeError:
|
||||
raise UFOLibError("The specified layer name is not a Unicode string.")
|
||||
directory = userNameToFileName(layerName, existing=existing, prefix="glyphs.")
|
||||
|
@ -2,7 +2,7 @@
|
||||
User name to file name conversion.
|
||||
This was taken form the UFO 3 spec.
|
||||
"""
|
||||
from fontTools.misc.py23 import unicode
|
||||
from fontTools.misc.py23 import basestring, unicode
|
||||
|
||||
|
||||
illegalCharacters = "\" * + / : < > ? [ \ ] | \0".split(" ")
|
||||
@ -68,7 +68,8 @@ def userNameToFileName(userName, existing=[], prefix="", suffix=""):
|
||||
u'alt._con'
|
||||
"""
|
||||
# the incoming name must be a unicode string
|
||||
assert isinstance(userName, unicode), "The value for userName must be a unicode string."
|
||||
if not isinstance(userName, unicode):
|
||||
raise ValueError("The value for userName must be a unicode string.")
|
||||
# establish the prefix and suffix lengths
|
||||
prefixLength = len(prefix)
|
||||
suffixLength = len(suffix)
|
||||
|
@ -15,7 +15,7 @@ from __future__ import unicode_literals
|
||||
import os
|
||||
from io import BytesIO, open
|
||||
from warnings import warn
|
||||
from fontTools.misc.py23 import tobytes
|
||||
from fontTools.misc.py23 import tobytes, unicode
|
||||
from ufoLib.plistlib import PlistWriter, readPlist, writePlist
|
||||
from ufoLib.plistFromETree import readPlistFromTree
|
||||
from ufoLib.pointPen import AbstractPointPen, PointToSegmentPen
|
||||
@ -457,9 +457,9 @@ def glyphNameToFileName(glyphName, glyphSet):
|
||||
existing = [name.lower() for name in list(glyphSet.contents.values())]
|
||||
else:
|
||||
existing = []
|
||||
if not isinstance(glyphName, basestring):
|
||||
if not isinstance(glyphName, unicode):
|
||||
try:
|
||||
new = str(glyphName)
|
||||
new = unicode(glyphName)
|
||||
glyphName = new
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
|
Loading…
x
Reference in New Issue
Block a user