@@ -304,31 +304,38 @@ def _cuda_core_version() -> str:
304304
305305
306306# ProgramOptions fields gated by plain truthiness in ``_program.pyx`` (the
307- # compiler writes the flag only when the value is truthy). For every other
308- # field listed in the cache-guard sets, the compiler uses ``is not None``,
309- # so even ``False`` / ``""`` must count as set.
307+ # compiler writes the flag only when the value is truthy).
310308_BOOLEAN_OPTION_FIELDS = frozenset ({"pch" })
311309
310+ # Fields whose compiler emission requires ``isinstance(value, str)`` or a
311+ # non-empty sequence; anything else (``False``, ``int``, ``None``, ``[]``)
312+ # is silently ignored at compile time.
313+ _STR_OR_SEQUENCE_OPTION_FIELDS = frozenset ({"include_path" , "pre_include" })
314+
312315
313316def _option_is_set (options : ProgramOptions , name : str ) -> bool :
314- """Match how ``_program.pyx`` gates option emission.
315-
316- - For boolean flags (``pch``): value must be truthy.
317- - For sequence-shaped fields (``include_path``, ``pre_include``): ``None ``
318- or an empty ``list``/``tuple`` counts as absent; any other value
319- (including the empty string, which NVRTC still emits as ``--flag= ``)
320- is set .
321- - For path /string-shaped fields (``create_pch``, ``time``,
317+ """Match how ``_program.pyx`` gates option emission, per field shape .
318+
319+ - Boolean flags (``pch``): truthy only .
320+ - str-or-sequence fields (``include_path``, ``pre_include``): ``str ``
321+ (including empty) or a non- empty ``list``/``tuple``; everything else
322+ (``False``, ``int``, empty sequence, ``None ``) is ignored by the
323+ compiler and must not trigger a cache-time guard .
324+ - Path /string-shaped fields (``create_pch``, ``time``,
322325 ``fdevice_time_trace``, ``use_pch``, ``pch_dir``): ``is not None`` --
323326 the compiler emits ``--flag=<value>`` for any non-None value, so
324- ``False``/ ``""``/ ``0`` must still count as set.
327+ ``False`` / ``""`` / ``0`` must still count as set.
325328 """
326329 value = getattr (options , name , None )
327330 if value is None :
328331 return False
329332 if name in _BOOLEAN_OPTION_FIELDS :
330333 return bool (value )
331- return not (isinstance (value , (list , tuple )) and len (value ) == 0 )
334+ if name in _STR_OR_SEQUENCE_OPTION_FIELDS :
335+ if isinstance (value , str ):
336+ return True
337+ return isinstance (value , (list , tuple )) and len (value ) > 0
338+ return True
332339
333340
334341def make_program_cache_key (
0 commit comments