Bug 1380159 - <type 'exceptions.TypeError'>: 'str' object does not support item assignment
Summary: <type 'exceptions.TypeError'>: 'str' object does not support item assignment
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: hwdata
Version: 7.3
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: rc
: ---
Assignee: Vitezslav Crhonek
QA Contact: Rachel Sibley
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-28 19:34 UTC by John Sefler
Modified: 2016-11-04 07:38 UTC (History)
3 users (show)

Fixed In Version: hwdata-0.252-8.4.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-04 07:38:29 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:2494 0 normal SHIPPED_LIVE hwdata bug fix and enhancement update 2016-11-03 14:11:22 UTC

Description John Sefler 2016-09-28 19:34:43 UTC
Description of problem:
After upgrading from hwdata-0.252-8.2.el7.x86_64 to hwdata-0.252-8.3.el7.x86_64 from the latest-RHEL-7 nightly compose, automated testing with rhnreg_ks fails to register to a satellite 5 server with the following Traceback...

[Wed Sep 28 14:45:18 2016] up2date 
Traceback (most recent call last):
  File "/usr/sbin/rhnreg_ks", line 218, in <module>
    cli.run()
  File "/usr/share/rhn/up2date_client/rhncli.py", line 96, in run
    sys.exit(self.main() or 0)
  File "/usr/sbin/rhnreg_ks", line 101, in main
    hardwareList = hardware.Hardware()
  File "/usr/share/rhn/up2date_client/hardware.py", line 788, in Hardware
    allhw = get_devices()
  File "/usr/share/rhn/up2date_client/hardware_gudev.py", line 45, in get_devices
    'desc':     _get_device_desc(device),
  File "/usr/share/rhn/up2date_client/hardware_gudev.py", line 295, in _get_device_desc
    usb = USB()
  File "/usr/lib/python2.7/site-packages/hwdata.py", line 51, in __init__
    USB.devices[vendor][1][device][0][interface_id] = interface_name
<type 'exceptions.TypeError'>: 'str' object does not support item assignment

The offending file /usr/lib/python2.7/site-packages/hwdata.py is provided by package python-hwdata-1.7.3-4.el7.noarch

Opening the hwdata.py and putting in some print statements before line 51 to help troubleshoot, I found...

  print interface_name
        =returns=======> 0003 M26 - BT Smart Watch for Android Phones
  print interface_id
        =returns=======> 0e8d
  print USB.devices[vendor][1][device][0] 
        =returns=======> MT6227 phone

I'm not a python programmer, but it looks like USB.devices[vendor][1][device][0] is returning a string object rather than a data structure with an element index 0e8d.  Hence the traceback "'str' object does not support item assignment" is thrown.

My hardware is an x86_64 KVM guest running RHEL73 Snapshot 5 compose.

I suspect that a change from Bug 1292382 caused this regression.

[root@jsefler-rhel7 ~]# rpm -q --changelog hwdata | head
* Mon Sep 26 2016 Vitezslav Crhonek <vcrhonek> - 0.252-8.3
- Updated pci, usb and vendor ids.
- Resolves: rhbz#1292382

* Tue Jun 28 2016 Michal Minar <miminar> 0.252-8.2
- Updated pci, usb and vendor ids.
- Resolves: rhbz#1292382
- Resolves: rhbz#1291614
- Resolves: rhbz#1324198


Version-Release number of selected component (if applicable):
[root@jsefler-rhel7 ~]# rpm -q hwdata python-hwdata rhn-client-tools
hwdata-0.252-8.3.el7.x86_64
python-hwdata-1.7.3-4.el7.noarch
rhn-client-tools-2.0.2-8.el7.noarch


How reproducible:
always with hwdata-0.252-8.3.el7.x86_64
never with  hwdata-0.252-8.2.el7.x86_64


Steps to Reproduce:
ON A KVM GUEST RUNNING RHEL73 Snapshot 5...
[root@jsefler-rhel7 ~]# rhnreg_ks --serverUrl=https://rhsm-sat5.usersys.redhat.com/XMLRPC --username=rhsm-client --password=REDACTED --profilename=rhsm-automation.jsefler-rhel7.usersys.redhat.com --force --norhnsd --nopackages --novirtinfo --sslCACert=/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT_rhsm-sat5.usersys.redhat.com
An error has occurred:
<type 'exceptions.TypeError'>
See /var/log/up2date for more information
[root@jsefler-rhel7 ~]# tail /var/log/up2date
  File "/usr/share/rhn/up2date_client/hardware.py", line 788, in Hardware
    allhw = get_devices()
  File "/usr/share/rhn/up2date_client/hardware_gudev.py", line 45, in get_devices
    'desc':     _get_device_desc(device),
  File "/usr/share/rhn/up2date_client/hardware_gudev.py", line 295, in _get_device_desc
    usb = USB()
  File "/usr/lib/python2.7/site-packages/hwdata.py", line 51, in __init__
    USB.devices[vendor][1][device][0][interface_id] = interface_name
<type 'exceptions.TypeError'>: 'str' object does not support item assignment

[root@jsefler-rhel7 ~]# rpm -q --whatprovides /usr/lib/python2.7/site-packages/hwdata.py
python-hwdata-1.7.3-4.el7.noarch
[root@jsefler-rhel7 ~]# rpm -q python-hwdata --requires
hwdata
python(abi) = 2.7
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PartialHardlinkSets) <= 4.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1
[root@jsefler-rhel7 ~]# rpm -q --whatrequires python-hwdata
rhn-client-tools-2.0.2-8.el7.noarch
[root@jsefler-rhel7 ~]# 



Additional info:

AFTER DOWNGRADING PACKAGE hwdata BACK TO RHEL73 Snapshot 5, LIFE IS GOOD AGAIN...

[root@jsefler-rhel7 ~]# yum downgrade hwdata --enablerepo=snapshot5-rhel73-server --quiet -y
[root@jsefler-rhel7 ~]# rpm -q hwdata
hwdata-0.252-8.2.el7.x86_64
[root@jsefler-rhel7 ~]# rhnreg_ks --serverUrl=https://rhsm-sat5.usersys.redhat.com/XMLRPC --username=rhsm-client --password=REDACTED --profilename=rhsm-automation.jsefler-rhel7.usersys.redhat.com --force --norhnsd --nopackages --novirtinfo --sslCACert=/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT_rhsm-sat5.usersys.redhat.com
[root@jsefler-rhel7 ~]# 
[root@jsefler-rhel7 ~]# rhn-channel --list
rhel-x86_64-server-7
[root@jsefler-rhel7 ~]# 

I can successfully register to a Sat5 server with hwdata-0.252-8.2.el7 but not with hwdata-0.252-8.3.el7

Comment 1 Vitezslav Crhonek 2016-09-29 07:09:07 UTC
Hello John,

Thanks for investigation. It is caused by bad indentation of that item in usb.ids:

...
0e8d  MediaTek Inc.
	0003  MT6227 phone
		0e8d 0003  M26 - BT Smart Watch for Android Phones
	0004  MT6227 phone
...

Fixing the indentation of that line fixes the issue (although the whole item seems suspicious to me).

Just FI, this particular item [1] was changed on 2016-09-07 and yesterday's release of the upstream list ([2]) still contains this error. 

[1] https://usb-ids.gowdy.us/read/UD/0e8d/0003/0e8d0003
[2] http://www.linux-usb.org/usb.ids

Comment 2 Vitezslav Crhonek 2016-09-29 08:47:26 UTC
Upstream database maintainer has just fixed (removed) that wrong database entry, see [1]. The usb.ids file at [2] should be updated in next twenty four hours.

[1] https://usb-ids.gowdy.us/read/UD/0e8d/0003/0e8d0003
[2] http://www.linux-usb.org/usb.ids

Comment 4 Rachel Sibley 2016-09-29 12:11:56 UTC
ALL TESTS PASSED

Using the example.py script form python-hwdata pkg, verified the 'TypeError: 'str' object does not support item assignment' error is no longer generated after update

Before
================
[root@localhost hwdata]# rpm -q hwdata
hwdata-0.252-8.3.el7.x86_64

[root@localhost hwdata]#  python example.py 
Vendor: Compaq Computer Corporation
Device: NC3120 Fast Ethernet NIC
Traceback (most recent call last):
  File "example.py", line 19, in <module>
    usb = USB()
  File "/usr/lib/python2.7/site-packages/hwdata.py", line 51, in __init__
    USB.devices[vendor][1][device][0][interface_id] = interface_name
TypeError: 'str' object does not support item assignment

After
================
[root@localhost hwdata]# yum update hwdata-0.252-8.4.el7.x86_64.rpm

[root@localhost hwdata]# rpm -q hwdata
hwdata-0.252-8.4.el7.x86_64

[root@localhost hwdata]# python example.py 
Vendor: Compaq Computer Corporation
Device: NC3120 Fast Ethernet NIC
Vendor: Hewlett-Packard
Device: OfficeJet Pro K5300

Comment 6 errata-xmlrpc 2016-11-04 07:38:29 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2494.html


Note You need to log in before you can comment on or make changes to this bug.