File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
cuda_pathfinder/cuda/pathfinder/_dynamic_libs Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 5
5
import ctypes
6
6
import ctypes .util
7
7
import os
8
- from typing import Optional
8
+ from typing import Optional , cast
9
9
10
10
from cuda .pathfinder ._dynamic_libs .load_dl_common import LoadedDL
11
11
from cuda .pathfinder ._dynamic_libs .supported_nvidia_libs import SUPPORTED_LINUX_SONAMES
@@ -40,8 +40,11 @@ def _load_libdl() -> ctypes.CDLL:
40
40
41
41
42
42
def _dl_last_error () -> Optional [str ]:
43
- msg = LIBDL .dlerror ()
44
- return msg .decode () if msg else None
43
+ msg_bytes = cast (Optional [bytes ], LIBDL .dlerror ())
44
+ if not msg_bytes :
45
+ return None # no pending error
46
+ # Never raises; undecodable bytes are mapped to U+DC80..U+DCFF
47
+ return msg_bytes .decode ("utf-8" , "surrogateescape" )
45
48
46
49
47
50
def abs_path_for_dynamic_library (libname : str , handle : ctypes .CDLL ) -> str :
You can’t perform that action at this time.
0 commit comments