system-config-printer.py crashed with ValueError in reinit()

Bug #140887 reported by Martin Pitt
36
Affects Status Importance Assigned to Milestone
cupsys (Ubuntu)
Invalid
High
Till Kamppeter
python-cups (Ubuntu)
Fix Released
High
Unassigned
system-config-printer (Ubuntu)
Fix Released
High
Unassigned

Bug Description

Binary package hint: system-config-printer

For a few days now, system-config-printer crashes right on startup. This is not fixed with 0.7.75 yet.

ProblemType: Crash
Architecture: amd64
Date: Wed Sep 19 09:38:57 2007
DistroRelease: Ubuntu 7.10
ExecutablePath: /usr/share/system-config-printer/system-config-printer.py
InterpreterPath: /usr/bin/python2.5
NonfreeKernelModules: vmnet vmblock vmmon nvidia
Package: system-config-printer 0.7.74+svn1539-0ubuntu1
PackageArchitecture: all
ProcCmdline: python /usr/share/system-config-printer/system-config-printer.py
ProcCwd: /home/martin
ProcEnviron:
 PATH=/home/martin/bin:/usr/lib/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
 LANG=de_DE.UTF-8
 SHELL=/bin/bash
PythonArgs: ['/usr/share/system-config-printer/system-config-printer.py']
SourcePackage: system-config-printer
Title: system-config-printer.py crashed with ValueError in reinit()
Uname: Linux donald 2.6.22-11-generic #1 SMP Mon Sep 17 03:18:44 GMT 2007 x86_64 GNU/Linux

Tags: apport-crash
Revision history for this message
Martin Pitt (pitti) wrote :
Changed in system-config-printer:
assignee: nobody → till-kamppeter
importance: Undecided → High
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Pitti, can you attach your /etc/cups/printers.conf and all PPD files in /etc/cups/ppd/?

Changed in system-config-printer:
status: New → Incomplete
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Pitti, and attach also the /etc/cups/printers.conf and all PPD files in /etc/cups/ppd/ from the other machines in your network which are broadcasting their queues.

Revision history for this message
Martin Pitt (pitti) wrote :
Revision history for this message
Martin Pitt (pitti) wrote :

Attached. There are no network queues around.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

I have added your ML-1610 queue to my system now and for me it works (by hand-editing config files and restarting CUPS).

Pitti, did the problem only appear after updating CUPS to 1.3.2? My system is a 32-bit system still having CUPS 1.3.0.

Tim, can you look into this?

Revision history for this message
Martin Pitt (pitti) wrote :

Right, that might be related to cups 1.3.2. Maybe it's due to upstream change 6970?

      - The scheduler incorrectly used portrait as the default
        orientation (STR #2513)
--- scheduler/printers.c (revision 6969)
+++ scheduler/printers.c (revision 6970)
@@ -3228,8 +3228,8 @@
                   "number-up-default", 1);

   if (!cupsGetOption("orientation-requested", p->num_options, p->options))
- ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM,
- "orientation-requested-default", IPP_PORTRAIT);
+ ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_NOVALUE,
+ "orientation-requested-default", NULL, NULL);

   if (!cupsGetOption("notify-lease-duration", p->num_options, p->options))
     ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,

Revision history for this message
Tim Waugh (twaugh) wrote :

Try running this bit of Python and showing us the output:

#!/usr/bin/python
import cups
from pprint import *
c=cups.Connection()
for printer in c.getPrinters().keys():
    print printer
    pprint (c.getPrinterAttributes(printer))

Hopefully this will pin-point the attribute that has a weird IPP type. The '(unknown IPP tag)' string comes from pycups.

Revision history for this message
Tim Waugh (twaugh) wrote :

Oh, that will be it. Needs a pycups fix…

Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote :

I confirm that the problem occur since cupsys upgrade to 1.3.2

kagou@satori:~$ system-config-printer
Traceback (most recent call last):
  File "/usr/share/system-config-printer/system-config-printer.py", line 3925, in <module>
    main(start_printer, change_ppd)
  File "/usr/share/system-config-printer/system-config-printer.py", line 3899, in main
    mainwindow = GUI(start_printer, change_ppd)
  File "/usr/share/system-config-printer/system-config-printer.py", line 506, in __init__
    self.populateList(start_printer, change_ppd)
  File "/usr/share/system-config-printer/system-config-printer.py", line 665, in populateList
    self.on_tvMainList_cursor_changed(self.tvMainList)
  File "/usr/share/system-config-printer/system-config-printer.py", line 1524, in on_tvMainList_cursor_changed
    self.fillPrinterTab(name)
  File "/usr/share/system-config-printer/system-config-printer.py", line 1690, in fillPrinterTab
    option.reinit (value, supported=supported)
  File "/usr/share/system-config-printer/options.py", line 113, in reinit
    self.original_value = self.ipp_type (original_value)
ValueError: invalid literal for int() with base 10: '(unknown IPP tag)'
kagou@satori:~$

Revision history for this message
Martin Pitt (pitti) wrote :

Just for completeness and in case it's still necessary, here is the output of above Python commands.

Thank you!

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Mike Sweet's fix for STR #2513 (see the patch in pitti's comment above is broken. The option "orientation-requested" is integer and can have one of the values 3, 4, 5, or 6, or it can be not set. Mike's patch assigns a string to this option, which breaks client programs.

The fix is unrolling Mike's patch 6970 and putting back in my workaround patch fix_auto_rotate_images.dpatch (attached). And a new STR should be opened.

Moving bug to cupsys ...

Changed in system-config-printer:
status: Incomplete → Confirmed
Revision history for this message
Tim Waugh (twaugh) wrote :

Mike's patch does not assign a string -- it assigns a value of type IPP_TAG_NOVALUE. Unfortunately pycups translates this to a string because it doesn't know how to handle that type. I'm going to teach it to handle it as the Python 'None' value, and will teach system-config-printer to use its own idea of what the system default is for that option if it encounters None.

I do wonder why that CUPS option is included in the default set if it has no default value though.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Tim, the option should be not defined by default, which means auto-rotate for best fit on image files. If IPP_TAG_NOVALUE is legal for options of any data type, pycups needs to be able to handle this. system-config-printer should consider the option value "None" as the option not being defined. It should not impose a value to the option, to do not loose the functionality of the undefined state, as here the auto rotation.

Changed in system-config-printer:
importance: Undecided → High
status: New → Confirmed
Changed in python-cups:
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Please try the new cupsys packages from here:

http://www.linux-foundation.org/~till/tmp/ubuntu/gutsy/cupsys/

They have Mike's fix unrolled and my workaround put back.

Changed in cupsys:
status: Confirmed → In Progress
Changed in python-cups:
status: Confirmed → In Progress
Changed in system-config-printer:
status: Confirmed → In Progress
Revision history for this message
Tim Waugh (twaugh) wrote :

But this option is in the default set, i.e. add_printer_defaults() (in ipp.c) always adds it.

Should we treat it as an option that is always shown in the Job Options screen (i.e. one of the widgets that's placed in the page using glade), or should it be an 'extra' option that can be added afterwards, i.e. one of the dynamic options? To do this we would have to ignore the option altogether when it is of type IPP_TAG_NOVALUE.

This is quite a bad behaviour change in CUPS -- I don't know how we are meant to cope with CUPS 1.1/1.2 servers properly now. The orientation-requested option will always show there if we treat it as a dynamic option.

Revision history for this message
Tim Waugh (twaugh) wrote :

So, Till, I see your patch removes that option from the default set. However, CUPS 1.1 and 1.2 servers *will* still have that option in the default set, and we will exhibit bad behaviour there. In particular, the option will apparently be unable to be "deleted".

Revision history for this message
Tim Waugh (twaugh) wrote :

By the way, I released pycups-1.9.27 earlier today to handle IPP_TAG_NOVALUE as the Python value None. Please see current system-config-printer svn for the corresponding change I mentioned earlier.

Changed in cupsys:
status: In Progress → Invalid
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Tested Tim's fix on system-config-printer and python-cups with cupsys-1.3.2-1ubuntu1. Now it works correctly. No need for modifying CUPS, marked cupsys task as invalid. Will make available Gutsy packages for system-config-printer and python-cups soon.

Tim, thank you for the quick fix.

Pitti, and also thank you for your help on fixing this.

Revision history for this message
Tim Waugh (twaugh) wrote :

FWIW I'll be releasing 0.7.74.2 shortly, but I think you're following svn trunk anyway.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Tim, in general it is bad to have an option with certain choices where not giving the option at all gives a functionality, which is not available via the choices. Not giving an option should lead to the default choice on the server and not to a new state. The right way would be to add a choice to "orientation-requested" with the name "auto" which leads to automatic rotation. Then a GUI could simply show five choices: the four orientations manually set and the automatic selection.

Currently the best GUI representation of such an option would be:

--------------------------------------------------------
[ ] Manually set orientation
      Orientation: Portrait
                   Landscape
                   Reverse Landscape
                   Reverse Portrait
--------------------------------------------------------

The foldable list "Orientation" should be grayed if the "Manually set orientation" check box is not checked.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

I have made new packages of system-config-printer and python-cups with Tim's fixes:

http://www.linux-foundation.org/~till/tmp/ubuntu/gutsy/system-config-printer/
http://www.linux-foundation.org/~till/tmp/ubuntu/gutsy/python-cups/

They will go into Gutsy soon.

Changed in python-cups:
status: In Progress → Fix Committed
Changed in system-config-printer:
status: In Progress → Fix Committed
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Tim, the line which I removed with my workaround patch did not exist in CUPS 1,1 and CUPS 1.2 (probably therefore image auto rotation worked there). It was introduced in CUPS 1.3. Therefore I have made the test of removing it and this made the rotation working again.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Tim, I tested now and Mike's fix also leads to auto rotation working again.

In terms of default set it seems that the line which I have patched away in my workaround removed the option from the default set. Mike has done as a new feature/fix in CUPS 1.3 adding all (?) options to the default set. He did not take into account that the functionality of not supplying the option gets lost by that.

I think you should add to all enumerated-choice type options (except PPD options) one additional choice, call it "Auto", "Default", ... with which the user can opt for not supplying the option.This additional choice should be selected when querying the option tells that it is set to IPP_TAG_NOVALUE.

Revision history for this message
Martin Pitt (pitti) wrote :

Tim, Till, thanks a lot for your super-fast response! Uploaded.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

python-cups (1.9.27-0ubuntu1) gutsy; urgency=low

  * New upstream release
     o Handle IPP_TAG_NOVALUE tags, translating them to None (LP: #140887)

 -- Till Kamppeter <email address hidden> Wed, 19 Sep 2007 13:26:34 +0100

Changed in python-cups:
status: Fix Committed → Fix Released
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

system-config-printer (0.7.75+svn1557-0ubuntu1) gutsy; urgency=low

  * New upstream release
     o Subversion snapshot r1557
     o Let IPP_TAG_NOVALUE attributes have Python value None instead of a
       string (Fixes LP: #140887).
     o Handle IPP_TAG_NOVALUE by translating it to a valid default value.
  * debian/control: Updated "Maintainer:" field.
  * debian/control: Require at least python-cups 1.9.27, so that
    IPP_TAG_NOVALUE attributes get handled correctly.

 -- Till Kamppeter <email address hidden> Wed, 19 Sep 2007 14:36:40 +0100

Changed in system-config-printer:
status: Fix Committed → Fix Released
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Tim, with which criteria did you select which options you hardcode into the glade file and which ones are dynamic? How do you quyery the dynamic options from the server and discover their type, possible choices, range, UI names for option and choices, ...? If for an option everything would be correctly discovered (in our case of the orientation the five possible states of no value and the 4 forced orientations) then an option should be dynamic, if an option needs manual work as not all about it can be discovered and if every CUPS queue has it, it should be put into the glade file. Tim, if you do some work here, can you also fix bug 135321?

Revision history for this message
Tim Waugh (twaugh) wrote :

Which options are which:

First of all, all of the printer options from the default set (i.e. the "*-default" ones from getPrinterAttributes() when there are no admin-set options) are put into the glade file. We know in advance their types and (usually) supported values, either from a "*-supported" attribute or from CUPS documentation, and these are set in GUI.__init__.

Next, any "generally useful" options were also chosen and put into the glade file. These include things like the text options, lpi and cpi. All of the options (and many of their choices) in the glade file have user-presentable names that may be localized.

That leaves special case options, infrequently needed options, poorly documented options, and third-party filters options, any of which can be specified by option name.

As for determining type, possible choices and ranges, to a large degree this is given to us in the "*-supported" attribute corresponding to each option. For example, if it is of type IPP_TAG_RANGE then it tells us the end-points (pycups represents this as a 2-tuple). Of course, many options don't have a corresponding "*-supported" attribute, so we have to handle those as text.

I don't agree that if any option may be dynamic then it must. From a user interface perspective I think it makes a lot more sense to have commonly used options already there in the dialog. (This was in fact Mike Sweet's suggestion in the first place.)

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

OK. I agree.

So if the "Orientation" option is in the glade file we should add a fifth choice "Auto" or "Default" to it which makes the option not being sent along with the jobs.

Revision history for this message
Tim Waugh (twaugh) wrote :

See current svn, where the 'Reset' button is made insensitive when the option is not set, just as any other non-default-set option would be.

To really make it work right I think the 'Automatic rotation' choice needs to be dynamically added and removed from the drop-down list, depending on the state of the Reset button. I'll have a think about this. The trouble is that we can't do the same thing with spin-buttons or Booleans. Perhaps we need to treat orientation-requested as a special case that needs an 'Automatic rotation'-type choice.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Tim, the current SVN works nicely, perhaps not the perfect way to make a user interface but with the help of the reset button I can get to all the five states now (drop-down forces orientation, reset puts it to automatic). A real "Automatic Rotation" entry (and "Reset" putting it to whatever is the CUPS default) would make it much more user-friendly. The name "Automatic Rotation" for the fifth choice can only be used if one makes this option a special case, as the functionality of not supplying any other option has other meanings.

Your changes fix also bug 135321, at least for me.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

system-config-printer (0.7.75+svn1566-0ubuntu1) gutsy; urgency=low

  * New upstream release
     o Subversion snapshot r1566
     o Fixed crash when clicking on option reset buttons (LP: #135321)
     o Made it possible to remove the "Orientatian" setting completely
       by clicking its reset button (LP: #140887)

 -- Till Kamppeter <email address hidden> Wed, 19 Sep 2007 19:17:50 +0100

Revision history for this message
Tim Waugh (twaugh) wrote :

Till, try current svn in trunk. It adds an 'Automatic rotation' choice in that combo-box, which disappears when another choice is selected.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

I think it is more intuitive to leave the 'Automatic rotation' choice always in the combo-box, even if selecting it has the same meaning as clicking on "Reset". Users who want to switch from a forced orientation to automatic do not necessarily know that "Reset" does this action, but the 'Automatic rotation' choice they will easily understand.

Am I right that "Reset" (of every option) sets a parameter to the CUPS default (default which CUPS also uses when creating a new queue).

Revision history for this message
Tim Waugh (twaugh) wrote :

"Reset" removes any admin-set value, i.e. the printers.conf file ends up with that "Options" line removed.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.