From bf39d704d748fdd26aa4dc217ce17e250a127369 Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Fri, 27 Sep 2013 19:27:46 +0000 Subject: [PATCH] Fixed a bug that raised an error if a lexer is unknown --- dpaste/highlight.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dpaste/highlight.py b/dpaste/highlight.py index 84306b5..dc418fa 100644 --- a/dpaste/highlight.py +++ b/dpaste/highlight.py @@ -107,6 +107,9 @@ class NakedHtmlFormatter(HtmlFormatter): yield i, t def pygmentize(code_string, lexer_name=LEXER_DEFAULT): - lexer = lexer_name and get_lexer_by_name(lexer_name) \ - or PythonLexer() + try: + lexer = lexer_name and get_lexer_by_name(lexer_name) \ + or PythonLexer() + except Exception as e: + lexer = PythonLexer() return highlight(code_string, lexer, NakedHtmlFormatter())