Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exception causes in lexer.py #1478

Merged
merged 1 commit into from Jun 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions pygments/lexer.py
Expand Up @@ -148,10 +148,10 @@ def get_tokens(self, text, unfiltered=False):
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:
Expand Down Expand Up @@ -496,7 +496,7 @@ def _process_state(cls, unprocessed, processed, state):
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])

Expand Down