Skip to content

Malformed UTF-8 triggers unexpected exception #18

Description

@Araneidae

Calling caget on Python3 on a PV which returns a string which is not in UTF-8 format triggers an exception which is not reported to the caller. For example:

>>> from cothread.catools import *
>>> caget ('LI-RF-AMPL-01:KLY:T1')
19.278066635131836
>>> caget ('LI-RF-AMPL-01:KLY:T1', format=FORMAT_CTRL)
Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 232, in 'calling callback function'
  File "/scratch/hgs15624/local/venvs/burtinter-dhuzAW7m/lib/python3.7/site-packages/cothread/catools.py", line 587, in _caget_event_handler
    args.raw_dbr, args.type, args.count))
  File "/scratch/hgs15624/local/venvs/burtinter-dhuzAW7m/lib/python3.7/site-packages/cothread/dbr.py", line 829, in dbr_to_value
    raw_dbr.copy_attributes(result)
  File "/scratch/hgs15624/local/venvs/burtinter-dhuzAW7m/lib/python3.7/site-packages/cothread/dbr.py", line 244, in copy_attributes_ctrl
    other.units = py23.decode(ctypes.string_at(self.units))
  File "/scratch/hgs15624/local/venvs/burtinter-dhuzAW7m/lib/python3.7/site-packages/cothread/py23.py", line 56, in decode
    return s.decode('UTF-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 0: invalid start byte
Traceback (most recent call last):
  File "/scratch/hgs15624/local/venvs/burtinter-dhuzAW7m/lib/python3.7/site-packages/cothread/catools.py", line 155, in ca_timeout
    return event.Wait(timeout)
  File "/scratch/hgs15624/local/venvs/burtinter-dhuzAW7m/lib/python3.7/site-packages/cothread/cothread.py", line 768, in Wait
    self._WaitUntil(deadline)
  File "/scratch/hgs15624/local/venvs/burtinter-dhuzAW7m/lib/python3.7/site-packages/cothread/cothread.py", line 611, in _WaitUntil
    raise Timedout('Timed out waiting for event')
cothread.cothread.Timedout: Timed out waiting for event

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions