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

未关闭
#385 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@xovishnukosuri 已经在做这个了。

开始于 2026年3月14日。

  • #427 来自 @xovishnukosuri —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
python
领域
desktop

调研方向

从 printerproperties.py 的 add_job_option 开始,然后检查 options.py 中 OptionWidget 附近的代码,traceback 会在那里使用 int() 转换值。打开某台打印机的打印机属性来复现故障,并将 job-cancel-after 的 None 值处理方式与报告中提出的两种修复方案进行比较;当属性对话框能够在没有 traceback 的情况下打开时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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).

主要语言
Python
星标
209
派生
111
平均合并
2 天 3 小时
30 天内合并 PR
8

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

OpenPrinting/system-config-printer 的其他 Issue

查看 OpenPrinting/system-config-printer 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。