2to3 --fix=raise
diff --git a/Lib/fontTools/afmLib.py b/Lib/fontTools/afmLib.py
index 528131c..04277d1 100644
--- a/Lib/fontTools/afmLib.py
+++ b/Lib/fontTools/afmLib.py
@@ -116,7 +116,7 @@
continue
m = identifierRE.match(line)
if m is None:
- raise error, "syntax error in AFM file: " + `line`
+ raise error("syntax error in AFM file: " + `line`)
pos = m.regs[1][1]
word = line[:pos]
@@ -135,7 +135,7 @@
def parsechar(self, rest):
m = charRE.match(rest)
if m is None:
- raise error, "syntax error in AFM file: " + `rest`
+ raise error("syntax error in AFM file: " + `rest`)
things = []
for fr, to in m.regs[1:]:
things.append(rest[fr:to])
@@ -147,7 +147,7 @@
def parsekernpair(self, rest):
m = kernRE.match(rest)
if m is None:
- raise error, "syntax error in AFM file: " + `rest`
+ raise error("syntax error in AFM file: " + `rest`)
things = []
for fr, to in m.regs[1:]:
things.append(rest[fr:to])
@@ -172,7 +172,7 @@
def parsecomposite(self, rest):
m = compositeRE.match(rest)
if m is None:
- raise error, "syntax error in AFM file: " + `rest`
+ raise error("syntax error in AFM file: " + `rest`)
charname = m.group(1)
ncomponents = int(m.group(2))
rest = rest[m.regs[0][1]:]
@@ -180,7 +180,7 @@
while 1:
m = componentRE.match(rest)
if m is None:
- raise error, "syntax error in AFM file: " + `rest`
+ raise error("syntax error in AFM file: " + `rest`)
basechar = m.group(1)
xoffset = int(m.group(2))
yoffset = int(m.group(3))
@@ -293,7 +293,7 @@
if attr in self._attrs:
return self._attrs[attr]
else:
- raise AttributeError, attr
+ raise AttributeError(attr)
def __setattr__(self, attr, value):
# all attrs *not* starting with "_" are consider to be AFM keywords
@@ -308,12 +308,12 @@
try:
del self.__dict__[attr]
except KeyError:
- raise AttributeError, attr
+ raise AttributeError(attr)
else:
try:
del self._attrs[attr]
except KeyError:
- raise AttributeError, attr
+ raise AttributeError(attr)
def __getitem__(self, key):
if type(key) == types.TupleType:
diff --git a/Lib/fontTools/agl.py b/Lib/fontTools/agl.py
index a3ed285..801a0b4 100644
--- a/Lib/fontTools/agl.py
+++ b/Lib/fontTools/agl.py
@@ -719,7 +719,7 @@
continue
m = parseAGL_RE.match(line)
if not m:
- raise AGLError, "syntax error in glyphlist.txt: %s" % repr(line[:20])
+ raise AGLError("syntax error in glyphlist.txt: %s" % repr(line[:20]))
unicode = m.group(1)
assert len(unicode) == 4
unicode = int(unicode, 16)
diff --git a/Lib/fontTools/cffLib.py b/Lib/fontTools/cffLib.py
index d754456..130249e 100644
--- a/Lib/fontTools/cffLib.py
+++ b/Lib/fontTools/cffLib.py
@@ -51,7 +51,7 @@
try:
index = self.fontNames.index(name)
except ValueError:
- raise KeyError, name
+ raise KeyError(name)
return self.topDictIndex[index]
def compile(self, file, otFont):
@@ -959,7 +959,7 @@
format = readCard8(file)
haveSupplement = format & 0x80
if haveSupplement:
- raise NotImplementedError, "Encoding supplements are not yet supported"
+ raise NotImplementedError("Encoding supplements are not yet supported")
format = format & 0x7f
if format == 0:
encoding = parseEncoding0(parent.charset, file, haveSupplement,
@@ -1485,7 +1485,7 @@
if value is None:
value = self.defaults.get(name)
if value is None:
- raise AttributeError, name
+ raise AttributeError(name)
conv = self.converters[name]
value = conv.read(self, value)
setattr(self, name, value)
diff --git a/Lib/fontTools/fondLib.py b/Lib/fontTools/fondLib.py
index b37a881..f06c752 100644
--- a/Lib/fontTools/fondLib.py
+++ b/Lib/fontTools/fondLib.py
@@ -34,7 +34,7 @@
def __init__(self, theRes, mode = 'r'):
self.ID, type, self.name = theRes.GetResInfo()
if type != 'FOND':
- raise ValueError, "FOND resource required"
+ raise ValueError("FOND resource required")
self.FOND = theRes
self.mode = mode
self.changed = 0
@@ -69,7 +69,7 @@
def save(self, destresfile = None):
if self.mode != 'w':
- raise error, "can't save font: no write permission"
+ raise error("can't save font: no write permission")
self._buildfontassociationtable()
self._buildoffsettable()
self._buildboundingboxtable()
@@ -246,7 +246,7 @@
for stylecode, table in tables:
data = data + struct.pack('>h', stylecode)
if len(table) != (3 + self.ffLastChar - self.ffFirstChar):
- raise error, "width table has wrong length"
+ raise error("width table has wrong length")
for width in table:
data = data + struct.pack('>h', width)
if DEBUG:
@@ -446,7 +446,7 @@
# XXX this goofs up MM font names: but how should it be done??
if famname:
if name[:len(famname)] != famname:
- raise error, "first part of name should be same as family name"
+ raise error("first part of name should be same as family name")
name = name[len(famname):]
split = [famname]
else:
@@ -478,7 +478,7 @@
elif mode == 'w':
permission = 3 # exclusive r/w
else:
- raise error, 'mode should be either "r" or "w"'
+ raise error('mode should be either "r" or "w"')
self.mode = mode
self.resref = Res.FSOpenResFile(path, permission)
Res.UseResFile(self.resref)
@@ -519,7 +519,7 @@
def __init__(self, fondlist):
import W
if not fondlist:
- raise ValueError, "expected at least one FOND entry"
+ raise ValueError("expected at least one FOND entry")
if len(fondlist) == 1:
self.choice = 0
return
diff --git a/Lib/fontTools/misc/homeResFile.py b/Lib/fontTools/misc/homeResFile.py
index b9463e4..2bdf1e4 100644
--- a/Lib/fontTools/misc/homeResFile.py
+++ b/Lib/fontTools/misc/homeResFile.py
@@ -70,7 +70,7 @@
ptr = buf.buffer_info()[0]
err = _getInfo(ptr)
if err:
- raise Res.Error, ("can't get file info", err)
+ raise Res.Error("can't get file info", err)
sstruct.unpack(_FCBPBFormat, buf.tostring(), self)
self.__haveInfo = 1
diff --git a/Lib/fontTools/misc/psCharStrings.py b/Lib/fontTools/misc/psCharStrings.py
index 9b2105b..2d4f0d8 100644
--- a/Lib/fontTools/misc/psCharStrings.py
+++ b/Lib/fontTools/misc/psCharStrings.py
@@ -291,7 +291,7 @@
try:
bytecode.extend(map(chr, opcodes[token]))
except KeyError:
- raise CharStringCompileError, "illegal operator: %s" % token
+ raise CharStringCompileError("illegal operator: %s" % token)
if token in ('hintmask', 'cntrmask'):
bytecode.append(program[i]) # hint mask
i = i + 1
diff --git a/Lib/fontTools/misc/sstruct.py b/Lib/fontTools/misc/sstruct.py
index fe1711b..9ab11aa 100644
--- a/Lib/fontTools/misc/sstruct.py
+++ b/Lib/fontTools/misc/sstruct.py
@@ -140,11 +140,11 @@
if m:
formatchar = m.group(1)
if formatchar != 'x' and formatstring:
- raise error, "a special format char must be first"
+ raise error("a special format char must be first")
else:
m = _elementRE.match(line)
if not m:
- raise error, "syntax error in format: '%s'" % line
+ raise error("syntax error in format: '%s'" % line)
name = m.group(1)
names.append(name)
formatchar = m.group(2)
@@ -154,7 +154,7 @@
after = int(m.group(4))
bits = before + after
if bits not in [8, 16, 32]:
- raise error, "fixed point must be 8, 16 or 32 bits long"
+ raise error("fixed point must be 8, 16 or 32 bits long")
formatchar = _fixedpointmappings[bits]
assert m.group(5) == "F"
fixes[name] = float(1 << after)
diff --git a/Lib/fontTools/misc/xmlReader.py b/Lib/fontTools/misc/xmlReader.py
index 8f7db3d..3251cc5 100644
--- a/Lib/fontTools/misc/xmlReader.py
+++ b/Lib/fontTools/misc/xmlReader.py
@@ -52,7 +52,7 @@
self.stackSize = stackSize + 1
if not stackSize:
if name != "ttFont":
- raise TTXParseError, "illegal root tag: %s" % name
+ raise TTXParseError("illegal root tag: %s" % name)
sfntVersion = attrs.get("sfntVersion")
if sfntVersion is not None:
if len(sfntVersion) != 4:
diff --git a/Lib/fontTools/nfntLib.py b/Lib/fontTools/nfntLib.py
index 3f48c4f..8e080d1 100644
--- a/Lib/fontTools/nfntLib.py
+++ b/Lib/fontTools/nfntLib.py
@@ -48,11 +48,11 @@
locTable = data[headerSize + bitmapSize:headerSize + bitmapSize + tableSize]
if len(locTable) != tableSize:
- raise ValueError, 'invalid NFNT format'
+ raise ValueError('invalid NFNT format')
owTable = data[headerSize + bitmapSize + tableSize:headerSize + bitmapSize + 2 * tableSize]
if len(owTable) != tableSize:
- raise ValueError, 'invalid NFNT format'
+ raise ValueError('invalid NFNT format')
# fill tables
self.offsetTable = []
@@ -185,7 +185,7 @@
def __getitem__(self, charNum):
if charNum > self.lastChar or charNum < 0:
- raise IndexError, "no such character"
+ raise IndexError("no such character")
index = charNum - self.firstChar
if index < 0:
return None
@@ -193,10 +193,10 @@
def __setitem__(self, charNum, glyph):
if charNum > self.lastChar or charNum < 0:
- raise IndexError, "no such character"
+ raise IndexError("no such character")
index = charNum - self.firstChar
if index < 0:
- raise IndexError, "no such character"
+ raise IndexError("no such character")
self.glyphs[index] = glyph
def __len__(self):
@@ -248,7 +248,7 @@
offset = self.offsetTable[cindex]
width = self.widthTable[cindex]
if offset == 255 and width == 255:
- raise ValueError, "character not defined"
+ raise ValueError("character not defined")
location0 = self.locTable[cindex]
location1 = self.locTable[cindex + 1]
srcbounds = (location0, 0, location1, self.fRectHeight)
diff --git a/Lib/fontTools/pens/basePen.py b/Lib/fontTools/pens/basePen.py
index 04da75a..b97ec60 100644
--- a/Lib/fontTools/pens/basePen.py
+++ b/Lib/fontTools/pens/basePen.py
@@ -248,7 +248,7 @@
elif n == 0:
self.lineTo(points[0])
else:
- raise AssertionError, "can't get there from here"
+ raise AssertionError("can't get there from here")
def qCurveTo(self, *points):
n = len(points) - 1 # 'n' is the number of control points
diff --git a/Lib/fontTools/t1Lib.py b/Lib/fontTools/t1Lib.py
index c482a10..eda2e52 100644
--- a/Lib/fontTools/t1Lib.py
+++ b/Lib/fontTools/t1Lib.py
@@ -152,7 +152,7 @@
res = Res.Get1Resource('POST', i)
code = ord(res.data[0])
if ord(res.data[1]) != 0:
- raise T1Error, 'corrupt LWFN file'
+ raise T1Error('corrupt LWFN file')
if code in [1, 2]:
if onlyHeader and code == 2:
break
@@ -166,7 +166,7 @@
elif code == 0:
pass # comment, ignore
else:
- raise T1Error, 'bad chunk code: ' + `code`
+ raise T1Error('bad chunk code: ' + `code`)
finally:
Res.CloseResFile(resRef)
data = string.join(data, '')
@@ -179,7 +179,7 @@
data = []
while 1:
if f.read(1) != chr(128):
- raise T1Error, 'corrupt PFB file'
+ raise T1Error('corrupt PFB file')
code = ord(f.read(1))
if code in [1, 2]:
chunklen = stringToLong(f.read(4))
@@ -189,7 +189,7 @@
elif code == 3:
break
else:
- raise T1Error, 'bad chunk code: ' + `code`
+ raise T1Error('bad chunk code: ' + `code`)
if onlyHeader:
break
f.close()
@@ -299,7 +299,7 @@
decrypted = decrypted[4:]
if decrypted[-len(EEXECINTERNALEND)-1:-1] != EEXECINTERNALEND \
and decrypted[-len(EEXECINTERNALEND)-2:-2] != EEXECINTERNALEND:
- raise T1Error, "invalid end of eexec part"
+ raise T1Error("invalid end of eexec part")
decrypted = decrypted[:-len(EEXECINTERNALEND)-2] + '\r'
data.append(EEXECBEGINMARKER + decrypted + EEXECENDMARKER)
else:
@@ -318,14 +318,14 @@
eBegin = eBegin + len(EEXECBEGIN) + 1
eEnd = string.find(data, EEXECEND, eBegin)
if eEnd < 0:
- raise T1Error, "can't find end of eexec part"
+ raise T1Error("can't find end of eexec part")
cypherText = data[eBegin:eEnd + 2]
if isHex(cypherText[:4]):
cypherText = deHexString(cypherText)
plainText, R = eexec.decrypt(cypherText, 55665)
eEndLocal = string.find(plainText, EEXECINTERNALEND)
if eEndLocal < 0:
- raise T1Error, "can't find end of eexec part"
+ raise T1Error("can't find end of eexec part")
chunks.append((0, data[:eBegin]))
chunks.append((1, cypherText[:eEndLocal + len(EEXECINTERNALEND) + 1]))
data = data[eEnd:]
@@ -345,11 +345,11 @@
if data[:len(head)] == head:
break
else:
- raise T1Error, "not a PostScript font"
+ raise T1Error("not a PostScript font")
if not _fontType1RE.search(data):
- raise T1Error, "not a Type 1 font"
+ raise T1Error("not a Type 1 font")
if string.find(data, "currentfile eexec") < 0:
- raise T1Error, "not an encrypted Type 1 font"
+ raise T1Error("not an encrypted Type 1 font")
# XXX what else?
return data
@@ -364,7 +364,7 @@
def stringToLong(str):
if len(str) != 4:
- raise ValueError, 'string must be 4 bytes long'
+ raise ValueError('string must be 4 bytes long')
long = 0
for i in range(4):
long = long + (ord(str[i]) << (i * 8))
diff --git a/Lib/fontTools/ttLib/__init__.py b/Lib/fontTools/ttLib/__init__.py
index 190d8e6..9f26e6c 100644
--- a/Lib/fontTools/ttLib/__init__.py
+++ b/Lib/fontTools/ttLib/__init__.py
@@ -401,14 +401,14 @@
table.decompile(data, self)
return table
else:
- raise KeyError, "'%s' table not found" % tag
+ raise KeyError("'%s' table not found" % tag)
def __setitem__(self, tag, table):
self.tables[tag] = table
def __delitem__(self, tag):
if tag not in self:
- raise KeyError, "'%s' table not found" % tag
+ raise KeyError("'%s' table not found" % tag)
if tag in self.tables:
del self.tables[tag]
if self.reader and tag in self.reader:
@@ -560,7 +560,7 @@
return self.getGlyphID(glyphName)
else:
if requireReal or not self.allowVID:
- raise KeyError, glyphName
+ raise KeyError(glyphName)
else:
# user intends virtual GID support
try:
@@ -627,7 +627,7 @@
debugmsg("Reading '%s' table from disk" % tag)
return self.reader[tag]
else:
- raise KeyError, tag
+ raise KeyError(tag)
def getGlyphSet(self, preferCFF=1):
"""Return a generic GlyphSet, which is a dict-like object
@@ -647,7 +647,7 @@
return _TTGlyphSet(self)
if "CFF " in self:
return self["CFF "].cff.values()[0].CharStrings
- raise TTLibError, "Font contains no outlines"
+ raise TTLibError("Font contains no outlines")
class _TTGlyphSet:
diff --git a/Lib/fontTools/ttLib/macUtils.py b/Lib/fontTools/ttLib/macUtils.py
index d9024a7..d65f70a 100644
--- a/Lib/fontTools/ttLib/macUtils.py
+++ b/Lib/fontTools/ttLib/macUtils.py
@@ -3,7 +3,7 @@
import sys
import os
if sys.platform not in ("mac", "darwin"):
- raise ImportError, "This module is Mac-only!"
+ raise ImportError("This module is Mac-only!")
import cStringIO
try:
@@ -49,7 +49,7 @@
for index in sfnts:
fonts.append(ttLib.TTFont(path, index))
if not fonts:
- raise ttLib.TTLibError, "no fonts found in file '%s'" % path
+ raise ttLib.TTLibError("no fonts found in file '%s'" % path)
return fonts
@@ -86,7 +86,7 @@
psname = ttFont['name'].getName(6, 1, 0) # PostScript name, etc.
if fullname is None or fullname is None or psname is None:
from fontTools import ttLib
- raise ttLib.TTLibError, "can't make 'sfnt' resource, no Macintosh 'name' table found"
+ raise ttLib.TTLibError("can't make 'sfnt' resource, no Macintosh 'name' table found")
self.fullname = fullname.string
self.familyname = familyname.string
self.psname = psname.string
diff --git a/Lib/fontTools/ttLib/sfnt.py b/Lib/fontTools/ttLib/sfnt.py
index 29355a9..035e51a 100644
--- a/Lib/fontTools/ttLib/sfnt.py
+++ b/Lib/fontTools/ttLib/sfnt.py
@@ -34,7 +34,7 @@
assert self.Version == 0x00010000 or self.Version == 0x00020000, "unrecognized TTC version 0x%08x" % self.Version
if not 0 <= fontNumber < self.numFonts:
from fontTools import ttLib
- raise ttLib.TTLibError, "specify a font number between 0 and %d (inclusive)" % (self.numFonts - 1)
+ raise ttLib.TTLibError("specify a font number between 0 and %d (inclusive)" % (self.numFonts - 1))
offsetTable = struct.unpack(">%dL" % self.numFonts, self.file.read(self.numFonts * 4))
if self.Version == 0x00020000:
pass # ignoring version 2.0 signatures
@@ -49,7 +49,7 @@
if self.sfntVersion not in ("\000\001\000\000", "OTTO", "true"):
from fontTools import ttLib
- raise ttLib.TTLibError, "Not a TrueType or OpenType font (bad sfntVersion)"
+ raise ttLib.TTLibError("Not a TrueType or OpenType font (bad sfntVersion)")
self.tables = {}
for i in range(self.numTables):
entry = self.DirectoryEntry()
@@ -141,7 +141,7 @@
assert not hasattr(entry.__class__, 'encodeData')
if len(data) != entry.length:
from fontTools import ttLib
- raise ttLib.TTLibError, "cannot rewrite '%s' table: length does not match directory entry" % tag
+ raise ttLib.TTLibError("cannot rewrite '%s' table: length does not match directory entry" % tag)
reuse = True
else:
entry = self.DirectoryEntry()
@@ -177,7 +177,7 @@
tables.sort()
if len(tables) != self.numTables:
from fontTools import ttLib
- raise ttLib.TTLibError, "wrong number of tables; expected %d, found %d" % (self.numTables, len(tables))
+ raise ttLib.TTLibError("wrong number of tables; expected %d, found %d" % (self.numTables, len(tables)))
if self.flavor == "woff":
self.signature = "wOFF"
diff --git a/Lib/fontTools/ttLib/tables/C_F_F_.py b/Lib/fontTools/ttLib/tables/C_F_F_.py
index 6162a87..53427b4 100644
--- a/Lib/fontTools/ttLib/tables/C_F_F_.py
+++ b/Lib/fontTools/ttLib/tables/C_F_F_.py
@@ -29,7 +29,7 @@
def getGlyphOrder(self):
if self._gaveGlyphOrder:
from fontTools import ttLib
- raise ttLib.TTLibError, "illegal use of getGlyphOrder()"
+ raise ttLib.TTLibError("illegal use of getGlyphOrder()")
self._gaveGlyphOrder = 1
return self.cff[self.cff.fontNames[0]].getGlyphOrder()
diff --git a/Lib/fontTools/ttLib/tables/DefaultTable.py b/Lib/fontTools/ttLib/tables/DefaultTable.py
index b32057d..2578eb7 100644
--- a/Lib/fontTools/ttLib/tables/DefaultTable.py
+++ b/Lib/fontTools/ttLib/tables/DefaultTable.py
@@ -30,7 +30,7 @@
from fontTools.misc.textTools import readHex
from fontTools import ttLib
if name != "hexdata":
- raise ttLib.TTLibError, "can't handle '%s' element" % name
+ raise ttLib.TTLibError("can't handle '%s' element" % name)
self.decompile(readHex(content), ttFont)
def __repr__(self):
diff --git a/Lib/fontTools/ttLib/tables/E_B_D_T_.py b/Lib/fontTools/ttLib/tables/E_B_D_T_.py
index 6ab1e05..758e633 100644
--- a/Lib/fontTools/ttLib/tables/E_B_D_T_.py
+++ b/Lib/fontTools/ttLib/tables/E_B_D_T_.py
@@ -390,9 +390,9 @@
def __getattr__(self, attr):
# Allow lazy decompile.
if attr[:2] == '__':
- raise AttributeError, attr
+ raise AttributeError(attr)
if not hasattr(self, "data"):
- raise AttributeError, attr
+ raise AttributeError(attr)
self.decompile()
del self.data
return getattr(self, attr)
diff --git a/Lib/fontTools/ttLib/tables/E_B_L_C_.py b/Lib/fontTools/ttLib/tables/E_B_L_C_.py
index 9c671c5..89b8348 100644
--- a/Lib/fontTools/ttLib/tables/E_B_L_C_.py
+++ b/Lib/fontTools/ttLib/tables/E_B_L_C_.py
@@ -332,9 +332,9 @@
def __getattr__(self, attr):
# Allow lazy decompile.
if attr[:2] == '__':
- raise AttributeError, attr
+ raise AttributeError(attr)
if not hasattr(self, "data"):
- raise AttributeError, attr
+ raise AttributeError(attr)
self.decompile()
del self.data, self.ttFont
return getattr(self, attr)
diff --git a/Lib/fontTools/ttLib/tables/O_S_2f_2.py b/Lib/fontTools/ttLib/tables/O_S_2f_2.py
index 7adbc18..a40e1e1 100644
--- a/Lib/fontTools/ttLib/tables/O_S_2f_2.py
+++ b/Lib/fontTools/ttLib/tables/O_S_2f_2.py
@@ -113,7 +113,7 @@
self.usUpperOpticalPointSize /= 20.
elif self.version != 0:
from fontTools import ttLib
- raise ttLib.TTLibError, "unknown format for OS/2 table: version %s" % self.version
+ raise ttLib.TTLibError("unknown format for OS/2 table: version %s" % self.version)
if len(data):
warnings.warn("too much 'OS/2' table data")
@@ -135,7 +135,7 @@
data = sstruct.pack(OS2_format_5, d)
else:
from fontTools import ttLib
- raise ttLib.TTLibError, "unknown format for OS/2 table: version %s" % self.version
+ raise ttLib.TTLibError("unknown format for OS/2 table: version %s" % self.version)
self.panose = panose
return data
diff --git a/Lib/fontTools/ttLib/tables/_c_m_a_p.py b/Lib/fontTools/ttLib/tables/_c_m_a_p.py
index a4ac714..918f89a 100644
--- a/Lib/fontTools/ttLib/tables/_c_m_a_p.py
+++ b/Lib/fontTools/ttLib/tables/_c_m_a_p.py
@@ -107,9 +107,9 @@
def __getattr__(self, attr):
# allow lazy decompilation of subtables.
if attr[:2] == '__': # don't handle requests for member functions like '__lt__'
- raise AttributeError, attr
+ raise AttributeError(attr)
if self.data == None:
- raise AttributeError, attr
+ raise AttributeError(attr)
self.decompile(None, None) # use saved data.
self.data = None # Once this table has been decompiled, make sure we don't
# just return the original data. Also avoids recursion when
diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py
index dfe3b5f..965fd79 100644
--- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py
+++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py
@@ -43,7 +43,7 @@
next = int(loca[i+1])
glyphdata = data[last:next]
if len(glyphdata) != (next - last):
- raise ttLib.TTLibError, "not enough 'glyf' table data"
+ raise ttLib.TTLibError("not enough 'glyf' table data")
glyph = Glyph(glyphdata)
self.glyphs[glyphName] = glyph
last = next
@@ -284,7 +284,7 @@
def fromXML(self, (name, attrs, content), ttFont):
if name == "contour":
if self.numberOfContours < 0:
- raise ttLib.TTLibError, "can't mix composites and contours in glyph"
+ raise ttLib.TTLibError("can't mix composites and contours in glyph")
self.numberOfContours = self.numberOfContours + 1
coordinates = GlyphCoordinates()
flags = []
@@ -307,7 +307,7 @@
self.endPtsOfContours.append(len(self.coordinates)-1)
elif name == "component":
if self.numberOfContours > 0:
- raise ttLib.TTLibError, "can't mix composites and contours in glyph"
+ raise ttLib.TTLibError("can't mix composites and contours in glyph")
self.numberOfContours = -1
if not hasattr(self, "components"):
self.components = []
@@ -559,7 +559,7 @@
def __getitem__(self, componentIndex):
if not self.isComposite():
- raise ttLib.TTLibError, "can't use glyph as sequence"
+ raise ttLib.TTLibError("can't use glyph as sequence")
return self.components[componentIndex]
def getCoordinates(self, glyfTable):
diff --git a/Lib/fontTools/ttLib/tables/_p_o_s_t.py b/Lib/fontTools/ttLib/tables/_p_o_s_t.py
index 02e3819..4a6ec1d 100644
--- a/Lib/fontTools/ttLib/tables/_p_o_s_t.py
+++ b/Lib/fontTools/ttLib/tables/_p_o_s_t.py
@@ -38,7 +38,7 @@
self.decode_format_3_0(data, ttFont)
else:
# supported format
- raise ttLib.TTLibError, "'post' table format %f not supported" % self.formatType
+ raise ttLib.TTLibError("'post' table format %f not supported" % self.formatType)
def compile(self, ttFont):
data = sstruct.pack(postFormat, self)
@@ -50,7 +50,7 @@
pass # we're done
else:
# supported format
- raise ttLib.TTLibError, "'post' table format %f not supported" % self.formatType
+ raise ttLib.TTLibError("'post' table format %f not supported" % self.formatType)
return data
def getGlyphOrder(self):
@@ -59,7 +59,7 @@
or its relatives instead!
"""
if not hasattr(self, "glyphOrder"):
- raise ttLib.TTLibError, "illegal use of getGlyphOrder()"
+ raise ttLib.TTLibError("illegal use of getGlyphOrder()")
glyphOrder = self.glyphOrder
del self.glyphOrder
return glyphOrder
diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py
index d556e63..cf99408 100644
--- a/Lib/fontTools/ttLib/tables/otBase.py
+++ b/Lib/fontTools/ttLib/tables/otBase.py
@@ -280,7 +280,7 @@
overflowErrorRecord = self.getOverflowErrorRecord(item)
- raise OTLOffsetOverflowError, overflowErrorRecord
+ raise OTLOffsetOverflowError(overflowErrorRecord)
return "".join(items)
@@ -514,14 +514,14 @@
if self.recurse > 2:
# shouldn't ever get here - we should only get to two levels of recursion.
# this guards against self.decompile NOT setting compileStatus to other than 1.
- raise AttributeError, attr
+ raise AttributeError(attr)
if self.compileStatus == 1:
self.ensureDecompiled()
val = getattr(self, attr)
self.recurse -=1
return val
- raise AttributeError, attr
+ raise AttributeError(attr)
"""Generic base class for all OpenType (sub)tables."""
diff --git a/Lib/fontTools/ttLib/tables/otConverters.py b/Lib/fontTools/ttLib/tables/otConverters.py
index 0555720..eb83214 100644
--- a/Lib/fontTools/ttLib/tables/otConverters.py
+++ b/Lib/fontTools/ttLib/tables/otConverters.py
@@ -58,19 +58,19 @@
def read(self, reader, font, tableDict):
"""Read a value from the reader."""
- raise NotImplementedError, self
+ raise NotImplementedError(self)
def write(self, writer, font, tableDict, value, repeatIndex=None):
"""Write a value to the writer."""
- raise NotImplementedError, self
+ raise NotImplementedError(self)
def xmlRead(self, attrs, content, font):
"""Read a value from XML."""
- raise NotImplementedError, self
+ raise NotImplementedError(self)
def xmlWrite(self, xmlWriter, font, value, name, attrs):
"""Write a value to XML."""
- raise NotImplementedError, self
+ raise NotImplementedError(self)
class SimpleValue(BaseConverter):
diff --git a/Lib/fontTools/ttLib/tables/ttProgram.py b/Lib/fontTools/ttLib/tables/ttProgram.py
index 490b0ab..2b65dad 100644
--- a/Lib/fontTools/ttLib/tables/ttProgram.py
+++ b/Lib/fontTools/ttLib/tables/ttProgram.py
@@ -278,7 +278,7 @@
while pos < lenAssembly:
m = _tokenRE.match(assembly, pos)
if m is None:
- raise tt_instructions_error, "Syntax error in TT program (%s)" % assembly[pos-5:pos+15]
+ raise tt_instructions_error("Syntax error in TT program (%s)" % assembly[pos-5:pos+15])
dummy, mnemonic, arg, number, comment = m.groups()
pos = m.regs[0][1]
if comment:
@@ -292,7 +292,7 @@
elif mnemonic not in ("NPUSHB", "NPUSHW", "PUSHB", "PUSHW"):
op, argBits = mnemonicDict[mnemonic]
if len(arg) != argBits:
- raise tt_instructions_error, "Incorrect number of argument bits (%s[%s])" % (mnemonic, arg)
+ raise tt_instructions_error("Incorrect number of argument bits (%s[%s])" % (mnemonic, arg))
if arg:
arg = binary2num(arg)
push(op + arg)
@@ -304,7 +304,7 @@
while pos < lenAssembly:
m = _tokenRE.match(assembly, pos)
if m is None:
- raise tt_instructions_error, "Syntax error in TT program (%s)" % assembly[pos:pos+15]
+ raise tt_instructions_error("Syntax error in TT program (%s)" % assembly[pos:pos+15])
dummy, mnemonic, arg, number, comment = m.groups()
if number is None and comment is None:
break
@@ -330,7 +330,7 @@
push(op)
push(nArgs)
else:
- raise tt_instructions_error, "More than 255 push arguments (%s)" % nArgs
+ raise tt_instructions_error("More than 255 push arguments (%s)" % nArgs)
if words:
for value in args:
push((value >> 8) & 0xff)