Skip to content

Commit

Permalink
Fix previous commit's unicode handling
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWells-diamond committed Nov 30, 2021
1 parent 08d1eb7 commit fd26bac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions softioc/device.py
Expand Up @@ -284,9 +284,9 @@ def truncate_string(value):
value = value.decode(errors="replace")
return value[:39] if isinstance(value, str) else None
else:
if isinstance(value, bytes):
if isinstance(value, bytes): # bytes == str in Python2
value = value.decode("utf-8", errors="replace")
return value[:39] if isinstance(value, str) else None
return value[:39] if isinstance(value, unicode) else None

longin = _Device_In('longin', value_to_epics=convert_to_int)
longout = _Device_Out('longout', value_to_epics=convert_to_int)
Expand Down

0 comments on commit fd26bac

Please sign in to comment.