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 28fb733

Browse filesBrowse files
committed
Make the serializer behave like a normal func with unknown kwargs
1 parent 556043b commit 28fb733
Copy full SHA for 28fb733

File tree

Expand file treeCollapse file tree

2 files changed

+7
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-1
lines changed

‎html5lib/serializer/htmlserializer.py

Copy file name to clipboardExpand all lines: html5lib/serializer/htmlserializer.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ def __init__(self, **kwargs):
155155
156156
.. _html5lib user documentation: http://code.google.com/p/html5lib/wiki/UserDocumentation
157157
"""
158+
unexpected_args = frozenset(kwargs) - frozenset(self.options)
159+
if len(unexpected_args) > 0:
160+
raise TypeError("__init__() got an unexpected keyword argument '%s'" % next(iter(unexpected_args)))
158161
if 'quote_char' in kwargs:
159162
self.use_best_quote_char = False
160163
for attr in self.options:

‎html5lib/tests/test_serializer.py

Copy file name to clipboardExpand all lines: html5lib/tests/test_serializer.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,12 @@ def _convertAttrib(self, attribs):
7979

8080
def serialize_html(input, options):
8181
options = dict([(str(k), v) for k, v in options.items()])
82+
encoding = options.get("encoding", None)
83+
if "encoding" in options:
84+
del options["encoding"]
8285
stream = Lint(JsonWalker(input), False)
8386
serializer = HTMLSerializer(alphabetical_attributes=True, **options)
84-
return serializer.render(stream, options.get("encoding", None))
87+
return serializer.render(stream, encoding)
8588

8689

8790
def runSerializerTest(input, expected, options):

0 commit comments

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