Bug 982071 - Python exception when selecting "install local driver": 'int' object has no attribute 'has_key' [PROPOSED FIX INCLUDED]
Python exception when selecting "install local driver": 'int' object has no a...
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: system-config-printer (Show other bugs)
19
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Tim Waugh
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-08 01:17 EDT by Johannes Goller
Modified: 2014-07-09 20:23 EDT (History)
3 users (show)

See Also:
Fixed In Version: system-config-printer-1.4.5-1.fc20
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-07-09 20:23:58 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Johannes Goller 2013-07-08 01:17:24 EDT
Description of problem:

When running system-config-printer (as root) to install a printer, I am unable to select a local printer driver (PPD): As soon as I click on the "local driver" in the "new printer" dialogue, the program stops working. On STDERR I get a Python exception (details below).


Version-Release number of selected component (if applicable):
system-config-printer 1.4.1_7.fc19

How reproducible: Always

Steps to Reproduce:
1. Run `sudo system-config-printer`
2. Select a printer for which no pre-packaged driver is available
3. Wait until the automated driver search has completed (not finding any driver); do not cancel the search procedure even if it takes 1 minute
4. Select "local driver"

Actual results:
A Python exception thrown on STDERR:

Traceback (most recent call last):
  File "/usr/share/system-config-printer/newprinter.py", line 892, in on_btnNPForward_clicked
    self.nextNPTab()
  File "/usr/share/system-config-printer/newprinter.py", line 1110, in nextNPTab
    if driver != None and driver.has_key ('packages'):
AttributeError: 'int' object has no attribute 'has_key'


Expected results:
The dialogue to continue.

Additional info:
As reported by the Python exception, the problem is caused by this line (line no. 1110) in newprinter.py:

if driver != None and driver.has_key ('packages'):


The reason is that `driver` is not actually `None`, but the integer `0`. I was able to fix the problem by replacing that line with the following

if driver is not None and driver != 0 and driver.has_key ('packages'):

With this in place, the dialogue continues and I am able to install the printer.
Comment 1 Johannes Goller 2013-07-08 01:26:08 EDT
Looking at the current version of the code (master branch), the line I mentioned seems to correspond to line 1125:

https://git.fedorahosted.org/cgit/system-config-printer.git/tree/newprinter.py#n1125

There are other lines in this code that compare `driver` (returned from `model.get_value()` to `None`. I suspect they all need to be prepared for the possibility of a value of `0` instead of `None`.
Comment 2 Jiri Popelka 2013-07-10 10:11:43 EDT
(In reply to Johannes Goller from comment #0)
> 4. Select "local driver"
I can't find any "local driver". I see only:
 * Select printer from database
 * Provide PPD file
 * Search for a printer driver to download

The affected code seem to handle the last case but I can't reproduce it.

> if driver is not None and driver != 0 and driver.has_key ('packages'):

nice, thanks, but we need to know how/why the 0 got there, it could contain other values, not just 0.
Comment 3 Johannes Goller 2013-07-10 10:28:01 EDT
>> 4. Select "local driver"
> I can't find any "local driver". I see only:
>  * Select printer from database
>  * Provide PPD file
>  * Search for a printer driver to download

I am sorry. I was looking at the Japanese version and made assumptions about the English original... It's the "provide a PPD file" option, then.

> nice, thanks, but we need to know how/why the 0 got there, it could contain other values, not just 0.

Sure, my fix is very ad-hoc.
Comment 4 Tim Waugh 2014-06-26 12:28:33 EDT
Tracked the cause of this down to commit b21756ca49e22feb3d055be331739707254516a7:

Commit:     Tim Waugh <twaugh@redhat.com>
CommitDate: Fri Nov 9 18:12:12 2012 +0000

    Avoid putting None in models whose columns don't allow it.

I should have checked for comparisons elsewhere in the code, and for some reason I missed this.

Thanks for the patch. I've applied it now.
Comment 5 Fedora Update System 2014-07-04 12:31:44 EDT
system-config-printer-1.4.5-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/system-config-printer-1.4.5-1.fc20
Comment 6 Fedora Update System 2014-07-05 10:55:37 EDT
Package system-config-printer-1.4.5-1.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing system-config-printer-1.4.5-1.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-8100/system-config-printer-1.4.5-1.fc20
then log in and leave karma (feedback).
Comment 7 Fedora Update System 2014-07-09 20:23:58 EDT
system-config-printer-1.4.5-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

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