Is this a duplicate?
Type of Bug
Runtime Error
Component
cuda.core
Describe the bug
ProgramOptions.name is annotated as accepting None:
name: str | None = "default_program"
but __post_init__ calls .encode() on it unconditionally:
def __post_init__(self) -> None:
self._name = self.name.encode()
So ProgramOptions(name=None) raises AttributeError: 'NoneType' object has no attribute 'encode'. The annotation and the docstring (name : str, optional) both read as permission to pass None.
This is the only field in __post_init__ whose None case is not handled. arch normalizes two lines below:
if self.arch is None:
self.arch = f"sm_{Device().arch}"
The failure happens at the .encode() call, before Device() is consulted, so it reproduces without a CUDA context.
How to Reproduce
from cuda.core import ProgramOptions
ProgramOptions(name=None)
Expected behavior
Either None is accepted and normalized to the documented default "default_program", matching how arch is handled in the same method, or the annotation is narrowed to str so the type no longer advertises a value that cannot be passed.
I have a patch for the first option and will open a PR shortly.
Additional context
The None path has no test coverage today: every ProgramOptions(name=...) in cuda_core/tests/test_program.py passes a string.
Is this a duplicate?
Type of Bug
Runtime Error
Component
cuda.core
Describe the bug
ProgramOptions.nameis annotated as acceptingNone:but
__post_init__calls.encode()on it unconditionally:So
ProgramOptions(name=None)raisesAttributeError: 'NoneType' object has no attribute 'encode'. The annotation and the docstring (name : str, optional) both read as permission to passNone.This is the only field in
__post_init__whoseNonecase is not handled.archnormalizes two lines below:The failure happens at the
.encode()call, beforeDevice()is consulted, so it reproduces without a CUDA context.How to Reproduce
Expected behavior
Either
Noneis accepted and normalized to the documented default"default_program", matching howarchis handled in the same method, or the annotation is narrowed tostrso the type no longer advertises a value that cannot be passed.I have a patch for the first option and will open a PR shortly.
Additional context
The
Nonepath has no test coverage today: everyProgramOptions(name=...)incuda_core/tests/test_program.pypasses a string.