From f06eb77387382c1d3142ae773e1d9b869158e183 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 30 Mar 2022 15:03:36 -0700 Subject: [PATCH] Remove bad ctypes patch (#2331) --- ...6-Don-t-dereference-function-pointer.patch | 34 ------------------- src/tests/python_tests.yaml | 7 +--- src/tests/test_core_python.py | 24 +++++-------- 3 files changed, 10 insertions(+), 55 deletions(-) delete mode 100644 cpython/patches/0006-Don-t-dereference-function-pointer.patch diff --git a/cpython/patches/0006-Don-t-dereference-function-pointer.patch b/cpython/patches/0006-Don-t-dereference-function-pointer.patch deleted file mode 100644 index 4410cc7d1..000000000 --- a/cpython/patches/0006-Don-t-dereference-function-pointer.patch +++ /dev/null @@ -1,34 +0,0 @@ -From d9b55121e5e0671efaa850096d3f816cee18479a Mon Sep 17 00:00:00 2001 -From: Hood -Date: Wed, 23 Jun 2021 13:47:30 -0700 -Subject: [PATCH 06/10] Don't dereference function pointer - -Ctypes thinks that the result of dlsym is a pointer to the function pointer, so -it should call it like `result = (*f)(args)`. Probably this is true for the -native dlsym, but our dlsym returns an index into the indirect call table -"wasmTable", in particular it isn't even aligned like a pointer should be. -This patch fixes it so that it calls it like `result = f(args)` instead. ---- - Modules/_ctypes/_ctypes.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c -index 5f8a723f63..379aa8a7d5 100644 ---- a/Modules/_ctypes/_ctypes.c -+++ b/Modules/_ctypes/_ctypes.c -@@ -778,7 +778,11 @@ CDataType_in_dll(PyObject *type, PyObject *args) - return NULL; - } - #endif -- return PyCData_AtAddress(type, address); -+ CDataObject *ob = (CDataObject *)GenericPyCData_new(type, NULL, NULL); -+ if (ob == NULL) -+ return NULL; -+ *(void **)ob->b_ptr = address; -+ return (PyObject*)ob; - } - - static const char from_param_doc[] = --- -2.25.1 - diff --git a/src/tests/python_tests.yaml b/src/tests/python_tests.yaml index 16eb9d3f3..12e69b06a 100644 --- a/src/tests/python_tests.yaml +++ b/src/tests/python_tests.yaml @@ -194,17 +194,12 @@ - test_callback_large_struct - CFunctions - test_struct_return_2H - - test_frozentable - FunctionTestCase - - test_an_integer - - test_optimizeflag - - test_pass_by_value_in_register - - test_struct_by_value + skip-node: - test_longlong_callbacks - test_longdouble - test_longlong - test_ulonglong - - test_curses - test_dataclasses - test_datetime: diff --git a/src/tests/test_core_python.py b/src/tests/test_core_python.py index 098a8134e..833d845f9 100644 --- a/src/tests/test_core_python.py +++ b/src/tests/test_core_python.py @@ -11,26 +11,20 @@ from pyodide_build.common import UNVENDORED_STDLIB_MODULES def filter_info(info: dict[str, Any], browser: str) -> dict[str, Any]: - info = dict(info) # keep only flags related to the current browser - flags_to_remove = ["firefox", "chrome", "node"] - flags_to_remove.remove(browser) - for browser in flags_to_remove: - for key in list(info.keys()): - if key.endswith(browser): - del info[key] - return info + suffix = "-" + browser + result = {key.removesuffix(suffix): value for key, value in info.items()} + if "skip" in info and f"skip{suffix}" in info: + result["skip"] = info["skip"] + info[f"skip{suffix}"] + return result def possibly_skip_test(request, info: dict[str, Any]) -> dict[str, Any]: - for reason in ( - reason for (flag, reason) in info.items() if flag.startswith("segfault") - ): - pytest.skip(f"known segfault: {reason}") + if "segfault" in info: + pytest.skip(f"known segfault: {info['segfault']}") - for reason in ( - reason for [flag, reason] in info.items() if flag.startswith("xfail") - ): + if "xfail" in info: + reason = info["xfail"] if request.config.option.run_xfail: request.applymarker( pytest.mark.xfail(