diff --git a/playwright/_impl/_fetch.py b/playwright/_impl/_fetch.py index e8b812b92..ac82eab38 100644 --- a/playwright/_impl/_fetch.py +++ b/playwright/_impl/_fetch.py @@ -394,7 +394,7 @@ async def _inner_fetch( post_data_buffer = data.encode() elif isinstance(data, bytes): post_data_buffer = data - elif isinstance(data, (dict, list, int, bool)): + elif isinstance(data, (dict, list, int, float, bool)): try: # NaN and Infinity are not valid JSON. json_data = json.dumps(data, allow_nan=False) diff --git a/tests/async/test_fetch_global.py b/tests/async/test_fetch_global.py index e09567f71..eabd84942 100644 --- a/tests/async/test_fetch_global.py +++ b/tests/async/test_fetch_global.py @@ -467,6 +467,7 @@ async def test_should_serialize_request_data( ([], "[]"), ({}, "{}"), ("", ""), + (1.5, "1.5"), ]: response = await request.post(server.PREFIX + "/echo", data=data) assert response.status == 200