Hello.
It seems that python3 version of PyTango 9.2.2 does not support indexing of DevFailed.
I tried the following code on python 2 and python3.
import tango
ex = None
try:
dev = tango.DeviceProxy('a/b/c') # This device does not exist
except tango.DevFailed as e:
ex = e
ex.args[0]# Works well
ex[0] # Fails on python3 with TypeError: 'DevFailed' object does not support indexing
I am not a PyTango expert but it seems like the DevFailed type has changed and you now need to specify ex.args[0] e.g.
In [37]: print(ex.args[0])
DevError[
desc = device a/b/c not defined in the database !
origin = DataBase::ImportDevice()
reason = DB_DeviceNotDefined
severity = ERR]
I missed that Exception API was changed.
It is not a huge problem. In my opinion, there is no need to provide full compatibility with old code.
Yes, Some problems could arise during porting python2 code to python3.
I think that the optimal solution is to create “Porting guideline” page in Docs.
Hi,
related to this issue, we did find a bug in pyutil.py in method __Util__create_device:
try:
db.import_device(device_name)
except DevFailed as df:
device_exists = not df[0].reason == “DB_DeviceNotDefined”
it should be:
try:
db.import_device(device_name)
except DevFailed as df:
device_exists = not df.args[0].reason == “DB_DeviceNotDefined”