diff options
author | Ram Rachum <ram@rachum.com> | 2020-06-11 23:04:19 +0300 |
---|---|---|
committer | Ram Rachum <ram@rachum.com> | 2020-06-11 23:04:19 +0300 |
commit | d5dbc4c886881a3a37a9f6fef09c6e29b47126c7 (patch) | |
tree | d7de40d4548075c33f7f350841df1bdd317533a3 /pygments/lexer.py | |
parent | 16bd34655497f2c9ffce02a2bf3d5b66bb06f526 (diff) | |
download | pygments-git-d5dbc4c886881a3a37a9f6fef09c6e29b47126c7.tar.gz |
Fix exception causes in lexer.py
Diffstat (limited to 'pygments/lexer.py')
-rw-r--r-- | pygments/lexer.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pygments/lexer.py b/pygments/lexer.py index b7aef6ec..41d74b19 100644 --- a/pygments/lexer.py +++ b/pygments/lexer.py @@ -148,10 +148,10 @@ class Lexer(metaclass=LexerMeta): elif self.encoding == 'chardet': try: import chardet - except ImportError: + except ImportError as e: raise ImportError('To enable chardet encoding guessing, ' 'please install the chardet library ' - 'from http://chardet.feedparser.org/') + 'from http://chardet.feedparser.org/') from e # check for BOM first decoded = None for bom, encoding in _encoding_map: @@ -496,7 +496,7 @@ class RegexLexerMeta(LexerMeta): rex = cls._process_regex(tdef[0], rflags, state) except Exception as err: raise ValueError("uncompilable regex %r in state %r of %r: %s" % - (tdef[0], state, cls, err)) + (tdef[0], state, cls, err)) from err token = cls._process_token(tdef[1]) |