Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit28fb733

Browse files
committed
Make the serializer behave like a normal func with unknown kwargs
1 parent556043b commit28fb733

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

‎html5lib/serializer/htmlserializer.py

Lines 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+
iflen(unexpected_args)>0:
160+
raiseTypeError("__init__() got an unexpected keyword argument '%s'"%next(iter(unexpected_args)))
158161
if'quote_char'inkwargs:
159162
self.use_best_quote_char=False
160163
forattrinself.options:

‎html5lib/tests/test_serializer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,12 @@ def _convertAttrib(self, attribs):
7979

8080
defserialize_html(input,options):
8181
options=dict([(str(k),v)fork,vinoptions.items()])
82+
encoding=options.get("encoding",None)
83+
if"encoding"inoptions:
84+
deloptions["encoding"]
8285
stream=Lint(JsonWalker(input),False)
8386
serializer=HTMLSerializer(alphabetical_attributes=True,**options)
84-
returnserializer.render(stream,options.get("encoding",None))
87+
returnserializer.render(stream,encoding)
8588

8689

8790
defrunSerializerTest(input,expected,options):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp