Use "is None" instead of "== None"
The latter hits the __eq__ method and can fail because we now
do not allow comparing objects of different types.
For example, was failing subsetting Andika-R.ttf.
diff --git a/Lib/fontTools/ttLib/tables/E_B_D_T_.py b/Lib/fontTools/ttLib/tables/E_B_D_T_.py
index ab2b8f4..35ab65c 100644
--- a/Lib/fontTools/ttLib/tables/E_B_D_T_.py
+++ b/Lib/fontTools/ttLib/tables/E_B_D_T_.py
@@ -172,7 +172,7 @@
# format allows the strike index value to be out of order.
if strikeIndex >= len(self.strikeData):
self.strikeData += [None] * (strikeIndex + 1 - len(self.strikeData))
- assert self.strikeData[strikeIndex] == None, "Duplicate strike EBDT indices."
+ assert self.strikeData[strikeIndex] is None, "Duplicate strike EBDT indices."
self.strikeData[strikeIndex] = bitmapGlyphDict
class EbdtComponent(object):
@@ -492,7 +492,7 @@
return (bitOffset, bitOffset+rowBits)
def getRow(self, row, bitDepth=1, metrics=None, reverseBytes=False):
- if metrics == None:
+ if metrics is None:
metrics = self.metrics
assert 0 <= row and row < metrics.height, "Illegal row access in bitmap"
@@ -541,7 +541,7 @@
return data
def setRows(self, dataRows, bitDepth=1, metrics=None, reverseBytes=False):
- if metrics == None:
+ if metrics is None:
metrics = self.metrics
if not reverseBytes:
dataRows = list(map(_reverseBytes, dataRows))
@@ -580,7 +580,7 @@
return (byteOffset, byteOffset+rowBytes)
def getRow(self, row, bitDepth=1, metrics=None, reverseBytes=False):
- if metrics == None:
+ if metrics is None:
metrics = self.metrics
assert 0 <= row and row < metrics.height, "Illegal row access in bitmap"
byteRange = self._getByteRange(row, bitDepth, metrics)
@@ -590,7 +590,7 @@
return data
def setRows(self, dataRows, bitDepth=1, metrics=None, reverseBytes=False):
- if metrics == None:
+ if metrics is None:
metrics = self.metrics
if reverseBytes:
dataRows = map(_reverseBytes, dataRows)
diff --git a/Lib/fontTools/ttLib/tables/E_B_L_C_.py b/Lib/fontTools/ttLib/tables/E_B_L_C_.py
index 1856fd7..f885318 100644
--- a/Lib/fontTools/ttLib/tables/E_B_L_C_.py
+++ b/Lib/fontTools/ttLib/tables/E_B_L_C_.py
@@ -219,7 +219,7 @@
# allows for the strike index value to be out of order.
if strikeIndex >= len(self.strikes):
self.strikes += [None] * (strikeIndex + 1 - len(self.strikes))
- assert self.strikes[strikeIndex] == None, "Duplicate strike EBLC indices."
+ assert self.strikes[strikeIndex] is None, "Duplicate strike EBLC indices."
self.strikes[strikeIndex] = curStrike
class Strike(object):
diff --git a/Lib/fontTools/ttLib/tables/G_M_A_P_.py b/Lib/fontTools/ttLib/tables/G_M_A_P_.py
index 6e8b322..57eb8f1 100644
--- a/Lib/fontTools/ttLib/tables/G_M_A_P_.py
+++ b/Lib/fontTools/ttLib/tables/G_M_A_P_.py
@@ -61,7 +61,7 @@
def compile(self, ttFont):
- if self.UV == None:
+ if self.UV is None:
self.UV = 0
nameLen = len(self.name)
if nameLen < 32:
diff --git a/Lib/fontTools/ttLib/tables/S_V_G_.py b/Lib/fontTools/ttLib/tables/S_V_G_.py
index 8d04811..e4d600c 100644
--- a/Lib/fontTools/ttLib/tables/S_V_G_.py
+++ b/Lib/fontTools/ttLib/tables/S_V_G_.py
@@ -202,7 +202,7 @@
svgDocData = bytesjoin(entryList)
# get colorpalette info.
- if self.colorPalettes == None:
+ if self.colorPalettes is None:
offsetToColorPalettes = 0
palettesData = ""
else:
@@ -258,7 +258,7 @@
writer.endtag("svgDoc")
writer.newline()
- if (self.colorPalettes != None) and (self.colorPalettes.numColorParams != None):
+ if (self.colorPalettes is not None) and (self.colorPalettes.numColorParams is not None):
writer.begintag("colorPalettes")
writer.newline()
for uiNameID in self.colorPalettes.colorParamUINameIDs:
diff --git a/Lib/fontTools/ttLib/tables/_c_m_a_p.py b/Lib/fontTools/ttLib/tables/_c_m_a_p.py
index b08c1ff..674a1fc 100644
--- a/Lib/fontTools/ttLib/tables/_c_m_a_p.py
+++ b/Lib/fontTools/ttLib/tables/_c_m_a_p.py
@@ -108,7 +108,7 @@
# allow lazy decompilation of subtables.
if attr[:2] == '__': # don't handle requests for member functions like '__lt__'
raise AttributeError(attr)
- if self.data == None:
+ if self.data is None:
raise AttributeError(attr)
self.decompile(None, None) # use saved data.
self.data = None # Once this table has been decompiled, make sure we don't
@@ -172,10 +172,10 @@
def decompile(self, data, ttFont):
# we usually get here indirectly from the subtable __getattr__ function, in which case both args must be None.
# If not, someone is calling the subtable decompile() directly, and must provide both args.
- if data != None and ttFont != None:
+ if data is not None and ttFont is not None:
self.decompileHeader(data[offset:offset+int(length)], ttFont)
else:
- assert (data == None and ttFont == None), "Need both data and ttFont arguments"
+ assert (data is None and ttFont is None), "Need both data and ttFont arguments"
data = self.data # decompileHeader assigns the data after the header to self.data
assert 262 == self.length, "Format 0 cmap subtable not 262 bytes"
glyphIdArray = array.array("B")
@@ -259,10 +259,10 @@
def decompile(self, data, ttFont):
# we usually get here indirectly from the subtable __getattr__ function, in which case both args must be None.
# If not, someone is calling the subtable decompile() directly, and must provide both args.
- if data != None and ttFont != None:
+ if data is not None and ttFont is not None:
self.decompileHeader(data[offset:offset+int(length)], ttFont)
else:
- assert (data == None and ttFont == None), "Need both data and ttFont arguments"
+ assert (data is None and ttFont is None), "Need both data and ttFont arguments"
data = self.data # decompileHeader assigns the data after the header to self.data
subHeaderKeys = []
@@ -628,10 +628,10 @@
def decompile(self, data, ttFont):
# we usually get here indirectly from the subtable __getattr__ function, in which case both args must be None.
# If not, someone is calling the subtable decompile() directly, and must provide both args.
- if data != None and ttFont != None:
+ if data is not None and ttFont is not None:
self.decompileHeader(self.data[offset:offset+int(length)], ttFont)
else:
- assert (data == None and ttFont == None), "Need both data and ttFont arguments"
+ assert (data is None and ttFont is None), "Need both data and ttFont arguments"
data = self.data # decompileHeader assigns the data after the header to self.data
(segCountX2, searchRange, entrySelector, rangeShift) = \
@@ -832,10 +832,10 @@
def decompile(self, data, ttFont):
# we usually get here indirectly from the subtable __getattr__ function, in which case both args must be None.
# If not, someone is calling the subtable decompile() directly, and must provide both args.
- if data != None and ttFont != None:
+ if data is not None and ttFont is not None:
self.decompileHeader(data[offset:offset+int(length)], ttFont)
else:
- assert (data == None and ttFont == None), "Need both data and ttFont arguments"
+ assert (data is None and ttFont is None), "Need both data and ttFont arguments"
data = self.data # decompileHeader assigns the data after the header to self.data
firstCode, entryCount = struct.unpack(">HH", data[:4])
@@ -918,10 +918,10 @@
def decompile(self, data, ttFont):
# we usually get here indirectly from the subtable __getattr__ function, in which case both args must be None.
# If not, someone is calling the subtable decompile() directly, and must provide both args.
- if data != None and ttFont != None:
+ if data is not None and ttFont is not None:
self.decompileHeader(data[offset:offset+int(length)], ttFont)
else:
- assert (data == None and ttFont == None), "Need both data and ttFont arguments"
+ assert (data is None and ttFont is None), "Need both data and ttFont arguments"
data = self.data # decompileHeader assigns the data after the header to self.data
charCodes = []
@@ -1084,10 +1084,10 @@
self.language = 0xFF # has no language.
def decompile(self, data, ttFont):
- if data != None and ttFont != None and ttFont.lazy:
+ if data is not None and ttFont is not None and ttFont.lazy:
self.decompileHeader(data, ttFont)
else:
- assert (data == None and ttFont == None), "Need both data and ttFont arguments"
+ assert (data is None and ttFont is None), "Need both data and ttFont arguments"
data = self.data
self.cmap = {} # so that clients that expect this to exist in a cmap table won't fail.
@@ -1145,9 +1145,9 @@
uvsList = sorted(uvsDict.keys())
for uvs in uvsList:
uvList = uvsDict[uvs]
- uvList.sort(key=lambda item: (item[1] != None, item[0], item[1]))
+ uvList.sort(key=lambda item: (item[1] is not None, item[0], item[1]))
for uv, gname in uvList:
- if gname == None:
+ if gname is None:
gname = "None"
# I use the arg rather than th keyword syntax in order to preserve the attribute order.
writer.simpletag("map", [ ("uvs",hex(uvs)), ("uv",hex(uv)), ("name", gname)] )
@@ -1196,7 +1196,7 @@
for uvs in uvsList:
entryList = uvsDict[uvs]
- defList = [entry for entry in entryList if entry[1] == None]
+ defList = [entry for entry in entryList if entry[1] is None]
if defList:
defList = [entry[0] for entry in defList]
defOVSOffset = offset
@@ -1223,7 +1223,7 @@
else:
defOVSOffset = 0
- ndefList = [entry for entry in entryList if entry[1] != None]
+ ndefList = [entry for entry in entryList if entry[1] is not None]
if ndefList:
nonDefUVSOffset = offset
ndefList.sort()
@@ -1273,10 +1273,10 @@
def decompile(self, data, ttFont):
# we usually get here indirectly from the subtable __getattr__ function, in which case both args must be None.
# If not, someone is calling the subtable decompile() directly, and must provide both args.
- if data != None and ttFont != None:
+ if data is not None and ttFont is not None:
self.decompileHeader(data[offset:offset+int(length)], ttFont)
else:
- assert (data == None and ttFont == None), "Need both data and ttFont arguments"
+ assert (data is None and ttFont is None), "Need both data and ttFont arguments"
def compile(self, ttFont):
if self.data:
diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py
index bf010b5..37d109d 100644
--- a/Lib/fontTools/ttLib/tables/otBase.py
+++ b/Lib/fontTools/ttLib/tables/otBase.py
@@ -373,7 +373,7 @@
continue
if appendExtensions:
- assert extTables != None, "Program or XML editing error. Extension subtables cannot contain extensions subtables"
+ assert extTables is not None, "Program or XML editing error. Extension subtables cannot contain extensions subtables"
newDone = {}
item._gatherTables(extTables, None, newDone)
diff --git a/Lib/fontTools/ttLib/tables/otTables.py b/Lib/fontTools/ttLib/tables/otTables.py
index 39820be..f4e8ac5 100644
--- a/Lib/fontTools/ttLib/tables/otTables.py
+++ b/Lib/fontTools/ttLib/tables/otTables.py
@@ -494,14 +494,14 @@
SubTable[0] and contents
...
SubTable[n] and contents
- If the offset to a lookup overflowed (SubTableIndex == None)
+ If the offset to a lookup overflowed (SubTableIndex is None)
we must promote the *previous* lookup to an Extension type.
If the offset from a lookup to subtable overflowed, then we must promote it
to an Extension Lookup type.
"""
ok = 0
lookupIndex = overflowRecord.LookupListIndex
- if (overflowRecord.SubTableIndex == None):
+ if (overflowRecord.SubTableIndex is None):
lookupIndex = lookupIndex - 1
if lookupIndex < 0:
return ok