From 28c7bac5424ddcc27d5f1e7db6484b372b338faa Mon Sep 17 00:00:00 2001 From: kwy404 Date: Thu, 24 Sep 2026 03:27:53 -0300 Subject: [PATCH] fix(fetch): accept float values for data --- playwright/_impl/_fetch.py | 2 +- tests/async/test_fetch_global.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/playwright/_impl/_fetch.py b/playwright/_impl/_fetch.py index 6181f22b2..aa5d78a7f 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)): json_data = json.dumps(data) else: raise Error(f"Unsupported 'data' type: {type(data)}") diff --git a/tests/async/test_fetch_global.py b/tests/async/test_fetch_global.py index 10f82583c..c6b33e577 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