Skip to content

Fix get_nested_resource_ptr to accept both str and bytes inputs#1665

Merged
rparolin merged 4 commits intoNVIDIA:mainfrom
rparolin:rparolin/get_nested_resource_fix
Feb 27, 2026
Merged

Fix get_nested_resource_ptr to accept both str and bytes inputs#1665
rparolin merged 4 commits intoNVIDIA:mainfrom
rparolin:rparolin/get_nested_resource_fix

Conversation

@rparolin
Copy link
Copy Markdown
Collaborator

@rparolin rparolin commented Feb 20, 2026

Summary

  • Fix get_nested_resource_ptr in utils.pyx to accept both str and bytes inputs for char resources, instead of only str via a Cython <str?> cast
  • Raise a clear TypeError when neither str nor bytes is provided
  • Add tests for bytes-encoded options in nvjitlink and nvvm

Closes #1354

🤖 Generated with Claude Code

The char resource path in get_nested_resource_ptr previously only handled
str inputs via a Cython <str?> cast, which would reject bytes objects.
This updates the logic to explicitly handle str, bytes, and raise a clear
TypeError for other types, enabling users to pass bytes-encoded options
to APIs like nvjitlink and nvvm.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@copy-pr-bot
Copy link
Copy Markdown
Contributor

copy-pr-bot bot commented Feb 20, 2026

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@rparolin rparolin requested a review from leofang February 20, 2026 06:15
@rparolin
Copy link
Copy Markdown
Collaborator Author

/ok to test

@rparolin rparolin added this to the cuda.bindings next milestone Feb 20, 2026
@github-actions
Copy link
Copy Markdown

@rparolin
Copy link
Copy Markdown
Collaborator Author

/ok to test

@rparolin rparolin requested a review from mdboom February 20, 2026 22:22
@Andy-Jost Andy-Jost added cuda.bindings Everything related to the cuda.bindings module enhancement Any code-related improvements labels Feb 24, 2026
@Andy-Jost Andy-Jost self-requested a review February 24, 2026 21:58
Copy link
Copy Markdown
Contributor

@Andy-Jost Andy-Jost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

The only thing I see is a type(obj) == str check rather than isinstance, but I don't think that's that big issue.

@rparolin rparolin merged commit 658bfb2 into NVIDIA:main Feb 27, 2026
90 checks passed
rparolin added a commit that referenced this pull request Feb 27, 2026
rparolin added a commit that referenced this pull request Feb 27, 2026
github-actions bot pushed a commit that referenced this pull request Feb 27, 2026
Removed preview folders for the following PRs:
- PR #1665
cpcloud pushed a commit to cpcloud/cuda-python that referenced this pull request Mar 3, 2026
…IA#1665)

* Fix get_nested_resource_ptr to accept both str and bytes inputs

The char resource path in get_nested_resource_ptr previously only handled
str inputs via a Cython <str?> cast, which would reject bytes objects.
This updates the logic to explicitly handle str, bytes, and raise a clear
TypeError for other types, enabling users to pass bytes-encoded options
to APIs like nvjitlink and nvvm.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* format

* Adding utf-8 as the byte encoding

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
cpcloud pushed a commit to cpcloud/cuda-python that referenced this pull request Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.bindings Everything related to the cuda.bindings module enhancement Any code-related improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make get_nested_resource_ptr support a nested sequence of bytes

3 participants