@@ -521,11 +521,9 @@ def __init__(
521521 else :
522522 try :
523523 hwid = self ._device_info .UniqueHardwareId .AsChar .decode ("ascii" )
524- except :
524+ except UnicodeDecodeError :
525525 guid = self ._device_info .UniqueHardwareId .AsGuid
526- hwid = "{{{0:x}-{1:x}-{2:x}-{3}}}" .format (
527- guid .Data1 , guid .Data2 , guid .Data3 , guid .Data4 .hex ()
528- )
526+ hwid = f"{{{ guid .Data1 :x} -{ guid .Data2 :x} -{ guid .Data3 :x} -{ guid .Data4 .hex ()} }}"
529527
530528 if (unique_hardware_id is None ) or (
531529 bytes (hwid , "ascii" ) == bytes (unique_hardware_id , "ascii" )
@@ -978,12 +976,10 @@ def get_ixxat_hwids():
978976 else :
979977 try :
980978 hwids .append (device_info .UniqueHardwareId .AsChar .decode ("ascii" ))
981- except :
979+ except UnicodeDecodeError :
982980 guid = device_info .UniqueHardwareId .AsGuid
983981 hwids .append (
984- "{{{0:x}-{1:x}-{2:x}-{3}}}" .format (
985- guid .Data1 , guid .Data2 , guid .Data3 , guid .Data4 .hex ()
986- )
982+ f"{{{ guid .Data1 :x} -{ guid .Data2 :x} -{ guid .Data3 :x} -{ guid .Data4 .hex ()} }}"
987983 )
988984 _canlib .vciEnumDeviceClose (device_handle )
989985
@@ -1011,11 +1007,9 @@ def _detect_available_configs() -> Sequence["AutoDetectedIxxatConfig"]:
10111007 else :
10121008 try :
10131009 hwid = device_info .UniqueHardwareId .AsChar .decode ("ascii" )
1014- except :
1010+ except UnicodeDecodeError :
10151011 guid = device_info .UniqueHardwareId .AsGuid
1016- hwid = "{{{0:x}-{1:x}-{2:x}-{3}}}" .format (
1017- guid .Data1 , guid .Data2 , guid .Data3 , guid .Data4 .hex ()
1018- )
1012+ hwid = f"{{{ guid .Data1 :x} -{ guid .Data2 :x} -{ guid .Data3 :x} -{ guid .Data4 .hex ()} }}"
10191013 _canlib .vciDeviceOpen (
10201014 ctypes .byref (device_info .VciObjectId ),
10211015 ctypes .byref (device_handle2 ),
0 commit comments