Skip to content

Comments

Fix get_nested_resource_ptr to accept both str and bytes inputs#1665

Open
rparolin wants to merge 4 commits intoNVIDIA:mainfrom
rparolin:rparolin/get_nested_resource_fix
Open

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

Conversation

@rparolin
Copy link
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
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
Collaborator Author

/ok to test

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

obj_i_bytes = (<str?>(obj_i)).encode()
obj_i_type = type(obj_i)
if obj_i_type is str:
obj_i_bytes = obj_i.encode()
Copy link
Contributor

Choose a reason for hiding this comment

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

We should specify an encoding here, since the default is system/installation specific prior to Python 3.15. Probably utf-8 is the right choice, unless the options aren't unicode-safe. The nvvm.h header doesn't really say...

@rparolin
Copy link
Collaborator Author

/ok to test

@rparolin rparolin requested a review from mdboom February 20, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make get_nested_resource_ptr support a nested sequence of bytes

2 participants