Skip to content

Commit 2d85f3e

Browse files
authored
Revert "Fix get_nested_resource_ptr to accept both str and bytes inputs (#1665)" (#1697)
This reverts commit 658bfb2.
1 parent 658bfb2 commit 2d85f3e

3 files changed

Lines changed: 3 additions & 21 deletions

File tree

cuda_bindings/cuda/bindings/_internal/utils.pyx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,7 @@ cdef int get_nested_resource_ptr(nested_resource[ResT] &in_out_ptr, object obj,
120120
nested_ptr.reset(nested_vec, True)
121121
for i, obj_i in enumerate(obj):
122122
if ResT is char:
123-
obj_i_type = type(obj_i)
124-
if obj_i_type is str:
125-
obj_i_bytes = obj_i.encode("utf-8")
126-
elif obj_i_type is bytes:
127-
obj_i_bytes = obj_i
128-
else:
129-
raise TypeError(
130-
f"Expected str or bytes, got {obj_i_type.__name__}")
123+
obj_i_bytes = (<str?>(obj_i)).encode()
131124
str_len = <size_t>(len(obj_i_bytes)) + 1 # including null termination
132125
deref(nested_res_vec)[i].resize(str_len)
133126
obj_i_ptr = <char*>(obj_i_bytes)

cuda_bindings/tests/test_nvjitlink.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,6 @@ def test_create_and_destroy(option):
9999
nvjitlink.destroy(handle)
100100

101101

102-
@pytest.mark.parametrize("option", ARCHITECTURES)
103-
def test_create_and_destroy_bytes_options(option):
104-
handle = nvjitlink.create(1, [f"-arch={option}".encode()])
105-
assert handle != 0
106-
nvjitlink.destroy(handle)
107-
108-
109102
@pytest.mark.parametrize("option", ARCHITECTURES)
110103
def test_complete_empty(option):
111104
handle = nvjitlink.create(1, [f"-arch={option}"])

cuda_bindings/tests/test_nvvm.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ def test_get_buffer_empty(get_size, get_buffer):
115115
assert buffer == b"\x00"
116116

117117

118-
@pytest.mark.parametrize(
119-
"options", [[], ["-opt=0"], ["-opt=3", "-g"], [b"-opt=0"], [b"-opt=3", b"-g"], ["-opt=3", b"-g"]]
120-
)
118+
@pytest.mark.parametrize("options", [[], ["-opt=0"], ["-opt=3", "-g"]])
121119
def test_compile_program_with_minimal_nvvm_ir(minimal_nvvmir, options): # noqa: F401, F811
122120
with nvvm_program() as prog:
123121
nvvm.add_module_to_program(prog, minimal_nvvmir, len(minimal_nvvmir), "FileNameHere.ll")
@@ -137,9 +135,7 @@ def test_compile_program_with_minimal_nvvm_ir(minimal_nvvmir, options): # noqa:
137135
assert ".visible .entry kernel()" in buffer.decode()
138136

139137

140-
@pytest.mark.parametrize(
141-
"options", [[], ["-opt=0"], ["-opt=3", "-g"], [b"-opt=0"], [b"-opt=3", b"-g"], ["-opt=3", b"-g"]]
142-
)
138+
@pytest.mark.parametrize("options", [[], ["-opt=0"], ["-opt=3", "-g"]])
143139
def test_verify_program_with_minimal_nvvm_ir(minimal_nvvmir, options): # noqa: F401, F811
144140
with nvvm_program() as prog:
145141
nvvm.add_module_to_program(prog, minimal_nvvmir, len(minimal_nvvmir), "FileNameHere.ll")

0 commit comments

Comments
 (0)