Handle float in _convert_js_arg

This fixes 'gg' with QtWebEngine.
This commit is contained in:
Florian Bruhin 2016-08-08 08:04:55 +02:00
parent 96087bd554
commit 627f743c26
2 changed files with 2 additions and 1 deletions

View File

@ -55,7 +55,7 @@ def _convert_js_arg(arg):
return 'undefined'
elif isinstance(arg, str):
return '"{}"'.format(string_escape(arg))
elif isinstance(arg, int):
elif isinstance(arg, (int, float)):
return str(arg)
else:
raise TypeError("Don't know how to handle {!r} of type {}!".format(

View File

@ -126,6 +126,7 @@ class TestStringEscape:
('foobar', '"foobar"'),
('foo\\bar', r'"foo\\bar"'),
(42, '42'),
(23.42, '23.42'),
(None, 'undefined'),
(object(), TypeError),
])