cuda.bindings: add decode_c_str helper for #2122#2148
Closed
aryanputta wants to merge 4 commits into
Closed
Conversation
- new pure-Python helper cuda.bindings._internal.strdecode.decode_c_str(data, api_name); success path unchanged from bytes.decode() - on UnicodeDecodeError, re-raises same exception type with reason extended to include CUDA API name + bounded hex preview (stop at first NUL with offset marker, cap 64 bytes with +N more) - exception type and __cause__ chain preserved so existing except UnicodeDecodeError keeps working - placed in _internal/ next to _fast_enum.py: no Cython rebuild, unit-testable without compiling extensions - generated .pyx call sites (nvml.error_string, nvvm.get_error_string, nvfatbin.get_error_string, cufile.cufileop_status_error) left untouched per cuda_bindings/CLAUDE.md; adoption belongs in next generator sync Implements the helper rwgk proposed inline on NVIDIA#2118. Refs NVIDIA#2118. Closes NVIDIA#2122. Signed-off-by: Aryan Putta <aryansputta@gmail.com>
Signed-off-by: Aryan Putta <aryansputta@gmail.com>
Drop tests that verified stdlib behavior or trivial format strings; keep the 11 that pin a non-obvious invariant (issue spec, codec/position preservation, NUL/cap markers). Signed-off-by: Aryan Putta <aryansputta@gmail.com>
No annotation in the file uses PEP 604 union syntax or forward references, so the import is unnecessary. Matches the style of the neighboring _fast_enum.py which does not carry it.
Contributor
|
For details, open this workflow run and click Summary. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
decode_c_str()helper incuda.bindings._internal.strdecodebytes.decode()UnicodeDecodeErrorwith the CUDA API name and a bounded hex preview for the failing bytesWhy
Issue #2122 asks for a more actionable
UnicodeDecodeErrorpath incuda.bindings. This keeps the change narrow and avoids touching generated binding call sites.Testing
cuda_bindings/cuda/bindings/_internal/strdecode.pyUnicodeDecodeError, and NUL-stop behavior on the error pathNotes
cuda_bindings/teststarget locally because the repo test harness imports compiled bindings and CUDA driver state fromconftest.py.pyxadoption can happen separatelyRelated