diff --git a/packages/wakatime/wakatime/packages/pygments/__init__.py b/packages/wakatime/wakatime/packages/pygments/__init__.py index 2bfd8ba..0f70768 100644 --- a/packages/wakatime/wakatime/packages/pygments/__init__.py +++ b/packages/wakatime/wakatime/packages/pygments/__init__.py @@ -43,7 +43,7 @@ def lex(code, lexer): """ try: return lexer.get_tokens(code) - except TypeError, err: + except (TypeError as err): if isinstance(err.args[0], str) and \ 'unbound method get_tokens' in err.args[0]: raise TypeError('lex() argument must be a lexer instance, ' @@ -67,7 +67,7 @@ def format(tokens, formatter, outfile=None): return realoutfile.getvalue() else: formatter.format(tokens, outfile) - except TypeError, err: + except (TypeError as err): if isinstance(err.args[0], str) and \ 'unbound method format' in err.args[0]: raise TypeError('format() argument must be a formatter instance, ' diff --git a/packages/wakatime/wakatime/packages/pygments/cmdline.py b/packages/wakatime/wakatime/packages/pygments/cmdline.py index c25204b..21095fe 100644 --- a/packages/wakatime/wakatime/packages/pygments/cmdline.py +++ b/packages/wakatime/wakatime/packages/pygments/cmdline.py @@ -202,7 +202,7 @@ def main(args=sys.argv): try: popts, args = getopt.getopt(args[1:], "l:f:F:o:O:P:LS:a:N:hVHg") - except getopt.GetoptError, err: + except (getopt.GetoptError as err): print >>sys.stderr, usage return 2 opts = {} @@ -279,9 +279,9 @@ def main(args=sys.argv): if infn is not None: try: lexer = get_lexer_for_filename(infn, **parsed_opts) - except ClassNotFound, err: + except (ClassNotFound as err): lexer = TextLexer() - except OptionError, err: + except (OptionError as err): print >>sys.stderr, 'Error:', err return 1 @@ -303,14 +303,14 @@ def main(args=sys.argv): try: parsed_opts['style'] = S_opt fmter = get_formatter_by_name(f_opt, **parsed_opts) - except ClassNotFound, err: + except (ClassNotFound as err): print >>sys.stderr, err return 1 arg = a_opt or '' try: print fmter.get_style_defs(arg) - except Exception, err: + except (Exception as err): print >>sys.stderr, 'Error:', err return 1 return 0 @@ -330,7 +330,7 @@ def main(args=sys.argv): if fmter: try: fmter = get_formatter_by_name(fmter, **parsed_opts) - except (OptionError, ClassNotFound), err: + except ((OptionError, ClassNotFound) as err): print >>sys.stderr, 'Error:', err return 1 @@ -338,12 +338,12 @@ def main(args=sys.argv): if not fmter: try: fmter = get_formatter_for_filename(outfn, **parsed_opts) - except (OptionError, ClassNotFound), err: + except ((OptionError, ClassNotFound) as err): print >>sys.stderr, 'Error:', err return 1 try: outfile = open(outfn, 'wb') - except Exception, err: + except (Exception as err): print >>sys.stderr, 'Error: cannot open outfile:', err return 1 else: @@ -356,7 +356,7 @@ def main(args=sys.argv): if lexer: try: lexer = get_lexer_by_name(lexer, **parsed_opts) - except (OptionError, ClassNotFound), err: + except ((OptionError, ClassNotFound) as err): print >>sys.stderr, 'Error:', err return 1 @@ -368,14 +368,14 @@ def main(args=sys.argv): infn = args[0] try: code = open(infn, 'rb').read() - except Exception, err: + except (Exception as err): print >>sys.stderr, 'Error: cannot read infile:', err return 1 if not lexer: try: lexer = get_lexer_for_filename(infn, code, **parsed_opts) - except ClassNotFound, err: + except (ClassNotFound as err): if '-g' in opts: try: lexer = guess_lexer(code, **parsed_opts) @@ -384,7 +384,7 @@ def main(args=sys.argv): else: print >>sys.stderr, 'Error:', err return 1 - except OptionError, err: + except (OptionError as err): print >>sys.stderr, 'Error:', err return 1 @@ -426,7 +426,7 @@ def main(args=sys.argv): for fname, fopts in F_opts: lexer.add_filter(fname, **fopts) highlight(code, lexer, fmter, outfile) - except Exception, err: + except (Exception as err): import traceback info = traceback.format_exception(*sys.exc_info()) msg = info[-1].strip() diff --git a/packages/wakatime/wakatime/packages/pygments/lexer.py b/packages/wakatime/wakatime/packages/pygments/lexer.py index 8f88dfd..6709d67 100644 --- a/packages/wakatime/wakatime/packages/pygments/lexer.py +++ b/packages/wakatime/wakatime/packages/pygments/lexer.py @@ -453,7 +453,7 @@ class RegexLexerMeta(LexerMeta): try: rex = cls._process_regex(tdef[0], rflags) - except Exception, err: + except (Exception as err): raise ValueError("uncompilable regex %r in state %r of %r: %s" % (tdef[0], state, cls, err))