From 77f0460446dfcdab0786ceff0962afde0e0a1a3c Mon Sep 17 00:00:00 2001 From: WyattBlue Date: Sat, 24 Oct 2026 13:12:22 -0400 Subject: [PATCH] Avoid GCC -Warray-bounds false positive in `VideoFrame.from_dlpack` `device_id not in (None, 0)` made Cython pass `Py_None` to an int comparison helper. The helper's `PyLong_CheckExact` guard makes this safe, but GCC can't evaluate it at compile time and warned about reads past `_Py_NoneStruct`. Check `is not None` first instead, here and in the same check in `_from_dlpack_planar`. --- av/video/frame.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/av/video/frame.py b/av/video/frame.py index 2ae742738..3e8f3e252 100644 --- a/av/video/frame.py +++ b/av/video/frame.py @@ -1661,7 +1661,7 @@ def from_dlpack( "device_id does not match the DLPack tensor device_id" ) else: - if device_id not in (None, 0): + if device_id is not None and device_id != 0: raise ValueError("device_id must be 0 for CPU tensors") device_id = 0 if dev_type0 == kCPU and (dev0 != 0 or dev1 != 0): @@ -1886,7 +1886,7 @@ def _from_dlpack_planar(planes, sw_fmt, format, width, height, stream, device_id ) expected_bits: cython.int = itemsize * 8 - if device_id not in (None, 0): + if device_id is not None and device_id != 0: raise ValueError("device_id must be 0 for CPU tensors") log2_w: cython.int = desc.log2_chroma_w