From 17d6259256444f6c0f943b58dea1b00b73113229 Mon Sep 17 00:00:00 2001 From: Harsh Kumar Date: Sun, 10 May 2026 12:08:13 +0530 Subject: [PATCH] fix(python_api): correct hasattr call for __array_interface__ check - Fix typo in hasattr call: change hasattr("obj", ...) to hasattr(obj, ...) - Ensures __array_interface__ attribute is checked on the actual object instead of the string literal "obj" - Prevents incorrect behavior when converting objects to numpy arrays --- src/_pytest/python_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index f6d5e31a588..b94752d2eab 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -906,6 +906,6 @@ def _as_numpy_array(obj: object) -> ndarray | None: return None elif isinstance(obj, np.ndarray): return obj - elif hasattr(obj, "__array__") or hasattr("obj", "__array_interface__"): + elif hasattr(obj, "__array__") or hasattr(obj, "__array_interface__"): return np.asarray(obj) return None