started moving to newer-style exception (finally)

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-05-16 23:02:22 +00:00
parent b725b91375
commit 9c2927df14
7 changed files with 9 additions and 9 deletions

View File

@ -623,7 +623,7 @@ class Application(object):
try: try:
pipe = Popen(args) pipe = Popen(args)
pipe.wait() pipe.wait()
except OSError, e: except OSError(e):
self.set_error("%s: %s" % (args[0], e)) self.set_error("%s: %s" % (args[0], e))
curses.reset_prog_mode() curses.reset_prog_mode()
self.win.redrawwin() self.win.redrawwin()

View File

@ -281,7 +281,7 @@ class Buffer(object):
llen = len(lines) llen = len(lines)
assert llen > 0 assert llen > 0
if not force and self.readonly(): if not force and self.readonly():
raise ReadOnlyError, "buffer is read-only" raise ReadOnlyError("buffer is read-only")
p2 = p.vadd(len(lines[-1]), llen - 1) p2 = p.vadd(len(lines[-1]), llen - 1)
if llen > 1: if llen > 1:
self.lines.insert(p.y + 1, []) self.lines.insert(p.y + 1, [])
@ -301,7 +301,7 @@ class Buffer(object):
def delete(self, p1, p2, act=ACT_NORM, force=False): def delete(self, p1, p2, act=ACT_NORM, force=False):
"""delete characters from p1 up to p2 from the buffer""" """delete characters from p1 up to p2 from the buffer"""
if not force and self.readonly(): if not force and self.readonly():
raise ReadOnlyError, "buffer is read-only" raise ReadOnlyError("buffer is read-only")
self._validate_point(p1) self._validate_point(p1)
self._validate_point(p2) self._validate_point(p2)
if p1 == p2: if p1 == p2:
@ -511,7 +511,7 @@ class FileBuffer(Buffer):
return self.checksum.digest() != m.digest() return self.checksum.digest() != m.digest()
def save(self, force=False): def save(self, force=False):
if self.readonly(): if self.readonly():
raise ReadOnlyError, "can't save read-only file" raise ReadOnlyError("can't save read-only file")
if self.checksum is not None and force is False: if self.checksum is not None and force is False:
# the file already existed and we took a checksum so make sure it's # the file already existed and we took a checksum so make sure it's

2
lex.py
View File

@ -124,7 +124,7 @@ class OverridePatternRule(PatternRule):
#lexer.mode.gstack['%s.start' % d['token']] = mode #lexer.mode.gstack['%s.start' % d['token']] = mode
lexer.mode.gstack['%s' % d['token']] = mode lexer.mode.gstack['%s' % d['token']] = mode
else: else:
raise OverrideError, "argh: %r" % mode raise OverrideError("argh: %r" % mode)
except (KeyError, AttributeError, OverrideError): except (KeyError, AttributeError, OverrideError):
pass pass
yield self.make_token(lexer, m.group(0), self.name, parent, d) yield self.make_token(lexer, m.group(0), self.name, parent, d)

View File

@ -898,7 +898,7 @@ class RegisterSave(Method):
h="Name of the register to use")] h="Name of the register to use")]
def _pre_execute(self, w, **vargs): def _pre_execute(self, w, **vargs):
if not w.has_kill(): if not w.has_kill():
raise MethodError, "No text on the kill stack" raise MethodError("No text on the kill stack")
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
name = vargs['name'] name = vargs['name']
text = w.get_kill() text = w.get_kill()

View File

@ -71,7 +71,7 @@ class Handler(object):
return None return None
self.curr_tokens = [] self.curr_tokens = []
self.last_sequence = sequence self.last_sequence = sequence
raise ActionError, "no action defined for %r" % (sequence) raise ActionError("no action defined for %r" % (sequence))
class Fundamental(Handler): class Fundamental(Handler):
'''This is the default mode''' '''This is the default mode'''

View File

@ -17,7 +17,7 @@ def _make_regex(w, s):
else: else:
return re.compile(s) return re.compile(s)
except: except:
raise searchutil.IllegalPatternError, "failed to compile: %r" % s raise searchutil.IllegalPatternError("failed to compile: %r" % s)
class SearchNext(method.Method): class SearchNext(method.Method):
def execute(self, w, **vargs): def execute(self, w, **vargs):

View File

@ -34,7 +34,7 @@ def find_ranges(r, w, start=None, end=None):
limit = len(w.buffer.lines[y]) limit = len(w.buffer.lines[y])
for m in r.finditer(w.buffer.lines[y], x, limit): for m in r.finditer(w.buffer.lines[y], x, limit):
if len(m.group(0)) == 0: if len(m.group(0)) == 0:
raise IllegalPatternError, "zero-width match found" raise IllegalPatternError("zero-width match found")
p1, p2 = Point(m.start(), y), Point(m.end(), y) p1, p2 = Point(m.start(), y), Point(m.end(), y)
hr = HighlightRegion(w, p1, p2, BG, UNSELECTED, match=m, name='search') hr = HighlightRegion(w, p1, p2, BG, UNSELECTED, match=m, name='search')
ranges.append(hr) ranges.append(hr)