MCPcopy
hub / github.com/pyodide/pyodide / test_get_empty_buffer

Function test_get_empty_buffer

src/tests/test_pyproxy.py:382–400  ·  view source on GitHub ↗

Previously empty buffers would raise alignment errors This is because when Python makes an empty buffer, apparently the pointer field is allowed to contain random garbage, which in particular won't be aligned.

(selenium)

Source from the content-addressed store, hash-verified

380
381@run_in_pyodide
382def test_get_empty_buffer(selenium):
383 """Previously empty buffers would raise alignment errors
384
385 This is because when Python makes an empty buffer, apparently the pointer
386 field is allowed to contain random garbage, which in particular won't be aligned.
387 """
388 from array import array
389
390 from pyodide.code import run_js
391
392 a = array("Q")
393 run_js(
394 """
395 (a) => {
396 let b = a.getBuffer();
397 b.release();
398 }
399 """
400 )(a)
401
402
403@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 1

run_jsFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…