Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 325aeaa

Browse filesBrowse files
jdufresnegsnedders
authored andcommitted
Add useful message to the ParseError exception.
Sometimes, I would like to be able to catch ParseError, and output its message immediately. Set the exception's message to the parser error message.
1 parent f644865 commit 325aeaa
Copy full SHA for 325aeaa

File tree

1 file changed

+2
-1
lines changed
Filter options

1 file changed

+2
-1
lines changed

‎html5lib/html5parser.py

Copy file name to clipboardExpand all lines: html5lib/html5parser.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from .constants import tokenTypes, ReparseException, namespaces
1919
from .constants import htmlIntegrationPointElements, mathmlTextIntegrationPointElements
2020
from .constants import adjustForeignAttributes as adjustForeignAttributesMap
21+
from .constants import E
2122

2223

2324
def parse(doc, treebuilder="etree", encoding=None,
@@ -256,7 +257,7 @@ def parseError(self, errorcode="XXX-undefined-error", datavars={}):
256257
# XXX The idea is to make errorcode mandatory.
257258
self.errors.append((self.tokenizer.stream.position(), errorcode, datavars))
258259
if self.strict:
259-
raise ParseError
260+
raise ParseError(E[errorcode] % datavars)
260261

261262
def normalizeToken(self, token):
262263
""" HTML5 specific normalizations to the token stream """

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.