From 9b529a23f64c4b27c427a2680428f3e17531e9c3 Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Tue, 18 Mar 2014 12:49:40 +0100 Subject: Python 3: use new style of raise, replace "raise class, args" with "raise class(args)" --- paste/evalexception/middleware.py | 3 +-- paste/exceptions/serial_number_generator.py | 2 +- paste/util/PySourceColor.py | 10 +++++----- paste/util/multidict.py | 4 ++-- paste/wsgiwrappers.py | 8 ++++---- 5 files changed, 13 insertions(+), 14 deletions(-) (limited to 'paste') diff --git a/paste/evalexception/middleware.py b/paste/evalexception/middleware.py index b6345c5..481d498 100644 --- a/paste/evalexception/middleware.py +++ b/paste/evalexception/middleware.py @@ -402,8 +402,7 @@ class DebugInfo(object): if id(frame) == tbid: return frame else: - raise ValueError, ( - "No frame by id %s found from %r" % (tbid, self.frames)) + raise ValueError("No frame by id %s found from %r" % (tbid, self.frames)) def wsgi_application(self, environ, start_response): start_response('200 OK', [('content-type', 'text/html')]) diff --git a/paste/exceptions/serial_number_generator.py b/paste/exceptions/serial_number_generator.py index 0289663..3bcdbe8 100644 --- a/paste/exceptions/serial_number_generator.py +++ b/paste/exceptions/serial_number_generator.py @@ -56,7 +56,7 @@ def hash_identifier(s, length, pad=True, hasher=md5, prefix='', # Accept sha/md5 modules as well as callables hasher = hasher.new if length > 26 and hasher is md5: - raise ValueError, ( + raise ValueError( "md5 cannot create hashes longer than 26 characters in " "length (you gave %s)" % length) if isinstance(s, unicode): diff --git a/paste/util/PySourceColor.py b/paste/util/PySourceColor.py index c2a9363..35efc7f 100644 --- a/paste/util/PySourceColor.py +++ b/paste/util/PySourceColor.py @@ -750,11 +750,11 @@ def cli(): linenumbers=linenumbers, header=header, footer=footer, form=form) else: - raise PathError, 'File does not exists!' + raise PathError('File does not exists!') else: try: if sys.stdin.isatty(): - raise InputError, 'Please check input!' + raise InputError('Please check input!') else: if output in [None,"-","stdout"]: str2stdout(sys.stdin.read(), colors=colorscheme, @@ -780,7 +780,7 @@ def cli(): show=show, markup=markup, quiet=quiet, header=header, footer=footer, linenumbers=linenumbers, form=form) else: - raise PathError, 'File does not exists!' + raise PathError('File does not exists!') Usage() ######################################################### Simple markup tests @@ -1009,7 +1009,7 @@ def convert(source, outdir=None, colors=None, path2file(source, outdir, colors, show, markup, quiet, form, header, footer, linenumbers, count) else: - raise PathError, 'File does not exist!' + raise PathError('File does not exist!') # If we pass in a dir we need to walkdir for files. # Then we need to colorize them with path2file else: @@ -1095,7 +1095,7 @@ def tagreplace(sourcestr, colors=lite, markup='xhtml', end = sourcestr[dataend+len(tagend):] sourcestr = ''.join([start,data,end]) else: - raise InputError,'Tag mismatch!\nCheck %s,%s tags'%tagstart,tagend + raise InputError('Tag mismatch!\nCheck %s,%s tags'%tagstart,tagend) if not dosheet: css = None return css, sourcestr diff --git a/paste/util/multidict.py b/paste/util/multidict.py index 867f309..d81cce0 100644 --- a/paste/util/multidict.py +++ b/paste/util/multidict.py @@ -145,8 +145,8 @@ class MultiDict(DictMixin): def pop(self, key, *args): if len(args) > 1: - raise TypeError, "pop expected at most 2 arguments, got "\ - + repr(1 + len(args)) + raise TypeError("pop expected at most 2 arguments, got " + + repr(1 + len(args))) for i in range(len(self._items)): if self._items[i][0] == key: v = self._items[i][1] diff --git a/paste/wsgiwrappers.py b/paste/wsgiwrappers.py index 7074923..9b614ec 100644 --- a/paste/wsgiwrappers.py +++ b/paste/wsgiwrappers.py @@ -451,8 +451,8 @@ class WSGIResponse(object): # See http://docs.python.org/lib/bltin-file-objects.html def write(self, content): if not self._is_str_iter: - raise IOError, "This %s instance's content is not writable: (content " \ - 'is an iterator)' % self.__class__.__name__ + raise IOError("This %s instance's content is not writable: (content " + 'is an iterator)' % self.__class__.__name__) self.content.append(content) def flush(self): @@ -460,8 +460,8 @@ class WSGIResponse(object): def tell(self): if not self._is_str_iter: - raise IOError, 'This %s instance cannot tell its position: (content ' \ - 'is an iterator)' % self.__class__.__name__ + raise IOError('This %s instance cannot tell its position: (content ' + 'is an iterator)' % self.__class__.__name__) return sum([len(chunk) for chunk in self._iter]) ######################################## -- cgit v1.2.1