Changeset 2783

Show
Ignore:
Timestamp:
11/26/19 03:46:31 (3 months ago)
Author:
jwoithe
Message:

mixer-qt4: type cast fix for python 3.8 in configuration.py.

Patch from David Runge:

After rebuilding against python 3.8 ffado-mixer crashes right after
starting when a device is connected:

----
File "/usr/lib/python3.8/site-packages/ffado/panelmanager.py", line 273,
in addPanel

dev = self.devices.getDeviceById( vendorId, modelId )

File "/usr/lib/python3.8/site-packages/ffado/configuration.py", line 58,
in getDeviceById

if int("%s" % devvendorid?, 0) == int("%s" % vendor, 0) and \
ValueError?: invalid literal for int() with base 0: 'dbus.Int32(2613)'

----

It seems that in the DeviceList? class in defined in
support/mixer-qt4/ffado/configuration.py, the member function
getDeviceById() accespts the "vendor" and "model" parameters to be of
type "str" or "dbus.Int32". The attempt to cast a dbus.Int32 to an int
fails.

This patch constains a somewhat rudimentary approach which casts "vendor"
and "model" to string if either are found to be of type dbus.Int32.

In addition to David's testing of python 3.8 the fix has been tested against
python 2.7.16. The code works against these two python versions, so no
difficulties are expected with any versions between them.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/support/mixer-qt4/ffado/configuration.py

    r2782 r2783  
    2222 
    2323import os 
     24import dbus 
    2425 
    2526import shlex 
     
    5455 
    5556    def getDeviceById( self, vendor, model ): 
     57        if isinstance(vendor, dbus.Int32): 
     58            vendor = str(int(vendor)) 
     59        if isinstance(model, dbus.Int32): 
     60            model = str(int(model)) 
     61 
    5662        log.debug("DeviceList::getDeviceById( %s, %s )" % (vendor, model )) 
    5763        for dev in self.devices: