OpenPrinting / OpenPrinting/system-config-printer

system-config-printer can't open printer properties because job-cancel-after value is None

Open
#385 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
204
Forks
108
Avg merge
1d 14h
Merged PRs (30d)
9

Description

I have system-config-printer 1.5.18-3 from Debian Testing. All my other CUPS etc. packages are up-to-date.

When I run system-config-printer, unlock it, and try to open the properties for a printer, nothing happens in the UI. In the terminal window from which I started system-config-printer I see a stack trace:

Traceback (most recent call last):
  File "/usr/share/system-config-printer/system-config-printer.py", line 597, in dests_iconview_item_activated
    self.propertiesDlg.show (name, host=self.connect_server,
  File "/usr/share/system-config-printer/printerproperties.py", line 579, in show
    self.load (name, host=host, encryption=encryption, parent=parent)
  File "/usr/share/system-config-printer/printerproperties.py", line 1457, in load
    self.add_job_option (option, value=value,
  File "/usr/share/system-config-printer/printerproperties.py", line 836, in add_job_option
    option = options.OptionWidget(name, value, supported,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/system-config-printer/options.py", line 84, in OptionWidget
    v = int(v)
        ^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

I modified printerproperties.py to indicate what option name and value are being processed right before this stack trace happens, and it said it was job-cancel-after with a value of None.

I don't know if this is the correct fix, but I made the problem go away with this change:

--- printerproperties.py~       2024-06-06 11:58:59.000000000 -0400
+++ printerproperties.py        2024-12-28 20:26:43.889878034 -0500
@@ -832,7 +832,7 @@
     def add_job_option(self, name, value = "", supported = "", is_new=True,
                        editable=True):
         try:
-            option = options.OptionWidget(name, value, supported,
+            option = options.OptionWidget(name, value or "", supported,
                                           self.option_changed)
         except ValueError:
             # We can't deal with this option type for some reason.

I suppose another option would be to change the except statement there from ValueError to (ValueError, TypeError).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in printerproperties.py at add_job_option, then inspect options.py around OptionWidget where the traceback converts the value with int(). Reproduce the failure by opening printer properties for a printer and compare the handling of the None job-cancel-after value with the two fixes proposed in the report; done means the properties dialog opens without the traceback.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.