From 9c2927df143cd5cdddb75adba4fb8163254030d3 Mon Sep 17 00:00:00 2001 From: moculus Date: Fri, 16 May 2008 23:02:22 +0000 Subject: [PATCH] started moving to newer-style exception (finally) --HG-- branch : pmacs2 --- application.py | 2 +- buffer.py | 6 +++--- lex.py | 2 +- method/__init__.py | 2 +- mode/__init__.py | 2 +- mode/search.py | 2 +- searchutil.py | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/application.py b/application.py index 8d35e68..8d0ae14 100755 --- a/application.py +++ b/application.py @@ -623,7 +623,7 @@ class Application(object): try: pipe = Popen(args) pipe.wait() - except OSError, e: + except OSError(e): self.set_error("%s: %s" % (args[0], e)) curses.reset_prog_mode() self.win.redrawwin() diff --git a/buffer.py b/buffer.py index 85f1154..3d166b3 100644 --- a/buffer.py +++ b/buffer.py @@ -281,7 +281,7 @@ class Buffer(object): llen = len(lines) assert llen > 0 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) if llen > 1: self.lines.insert(p.y + 1, []) @@ -301,7 +301,7 @@ class Buffer(object): def delete(self, p1, p2, act=ACT_NORM, force=False): """delete characters from p1 up to p2 from the buffer""" 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(p2) if p1 == p2: @@ -511,7 +511,7 @@ class FileBuffer(Buffer): return self.checksum.digest() != m.digest() def save(self, force=False): 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: # the file already existed and we took a checksum so make sure it's diff --git a/lex.py b/lex.py index 6f54733..4b91fa6 100755 --- a/lex.py +++ b/lex.py @@ -124,7 +124,7 @@ class OverridePatternRule(PatternRule): #lexer.mode.gstack['%s.start' % d['token']] = mode lexer.mode.gstack['%s' % d['token']] = mode else: - raise OverrideError, "argh: %r" % mode + raise OverrideError("argh: %r" % mode) except (KeyError, AttributeError, OverrideError): pass yield self.make_token(lexer, m.group(0), self.name, parent, d) diff --git a/method/__init__.py b/method/__init__.py index 247dbaa..896e895 100644 --- a/method/__init__.py +++ b/method/__init__.py @@ -898,7 +898,7 @@ class RegisterSave(Method): h="Name of the register to use")] def _pre_execute(self, w, **vargs): 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): name = vargs['name'] text = w.get_kill() diff --git a/mode/__init__.py b/mode/__init__.py index c915399..2dad4ef 100644 --- a/mode/__init__.py +++ b/mode/__init__.py @@ -71,7 +71,7 @@ class Handler(object): return None self.curr_tokens = [] self.last_sequence = sequence - raise ActionError, "no action defined for %r" % (sequence) + raise ActionError("no action defined for %r" % (sequence)) class Fundamental(Handler): '''This is the default mode''' diff --git a/mode/search.py b/mode/search.py index 369334f..7731328 100644 --- a/mode/search.py +++ b/mode/search.py @@ -17,7 +17,7 @@ def _make_regex(w, s): else: return re.compile(s) except: - raise searchutil.IllegalPatternError, "failed to compile: %r" % s + raise searchutil.IllegalPatternError("failed to compile: %r" % s) class SearchNext(method.Method): def execute(self, w, **vargs): diff --git a/searchutil.py b/searchutil.py index dd2559f..964777b 100644 --- a/searchutil.py +++ b/searchutil.py @@ -34,7 +34,7 @@ def find_ranges(r, w, start=None, end=None): limit = len(w.buffer.lines[y]) for m in r.finditer(w.buffer.lines[y], x, limit): 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) hr = HighlightRegion(w, p1, p2, BG, UNSELECTED, match=m, name='search') ranges.append(hr)