Skip to content

cuda.core: Change selected .decode() calls to .decode("utf-8", errors="backslashreplace") #510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cuda_core/cuda/core/experimental/_linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def get_error_log(self) -> str:
_nvjitlink.get_error_log(self._mnff.handle, log)
else:
log = self._options.formatted_options[2]
return log.decode()
return log.decode("utf-8", errors="backslashreplace")

def get_info_log(self) -> str:
"""Get the info log generated by the linker.
Expand All @@ -481,7 +481,7 @@ def get_info_log(self) -> str:
_nvjitlink.get_info_log(self._mnff.handle, log)
else:
log = self._options.formatted_options[0]
return log.decode()
return log.decode("utf-8", errors="backslashreplace")

def _input_type_from_code_type(self, code_type: str):
# this list is based on the supported values for code_type in the ObjectCode class definition.
Expand Down
2 changes: 1 addition & 1 deletion cuda_core/cuda/core/experimental/_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def compile(self, target_type, name_expressions=(), logs=None):
if logsize > 1:
log = b" " * logsize
handle_return(nvrtc.nvrtcGetProgramLog(self._mnff.handle, log), handle=self._mnff.handle)
logs.write(log.decode())
logs.write(log.decode("utf-8", errors="backslashreplace"))

return ObjectCode._init(data, target_type, symbol_mapping=symbol_mapping)

Expand Down
2 changes: 1 addition & 1 deletion cuda_core/cuda/core/experimental/_utils/cuda_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _check_error(error, handle=None):
_, logsize = nvrtc.nvrtcGetProgramLogSize(handle)
log = b" " * logsize
_ = nvrtc.nvrtcGetProgramLog(handle, log)
err += f", compilation log:\n\n{log.decode()}"
err += f", compilation log:\n\n{log.decode('utf-8', errors='backslashreplace')}"
raise NVRTCError(err)
else:
raise RuntimeError(f"Unknown error type: {error}")
Expand Down
Loading