From 458cd98087b344738a22eb5d7521cf2f1ebfd213 Mon Sep 17 00:00:00 2001 From: jrmccluskey Date: Tue, 13 Oct 2026 15:38:50 +0000 Subject: [PATCH] Catch alternate exception type in NumpyBatchConverter --- sdks/python/apache_beam/typehints/batch.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sdks/python/apache_beam/typehints/batch.py b/sdks/python/apache_beam/typehints/batch.py index b193c590bec4..5e18e7488084 100644 --- a/sdks/python/apache_beam/typehints/batch.py +++ b/sdks/python/apache_beam/typehints/batch.py @@ -188,7 +188,9 @@ def from_typehints(element_type, if not isinstance(element_type, NumpyTypeHint.NumpyTypeConstraint): try: element_type = NumpyArray[element_type, ()] - except TypeError as e: + # NumPy 2.4.6+ can also raise a value error if given a dtype that cannot + # be converted into a numpy dtype. + except (TypeError, ValueError) as e: raise TypeError("Element type is not a dtype") from e if not isinstance(batch_type, NumpyTypeHint.NumpyTypeConstraint):