Skip to content

Fix Printer Properties crash for None option values - #481

Merged
alexpevzner merged 1 commit into
masterfrom
fix/printer-properties-none-option
Oct 7, 2026
Merged

alexpevzner merged 1 commit into
masterfrom
fix/printer-properties-none-option

Conversation

@SinghCod3r

Copy link
Copy Markdown
Collaborator

Problem

Printer Properties can crash when a printer option has an IPP no-value default.

pycups converts an IPP no-value attribute to Python None. This value can then reach options.OptionWidget(), where numeric and string option handling assumes the value is convertible to the expected type.

This can result in an uncaught TypeError while opening Printer Properties.

The issue is not specific to job-cancel-after; it is a generic handling problem for None option values returned by CUPS.

Root Cause

The value flow is:

CUPS/IPP no-value
        ↓
pycups
        ↓
Python None
        ↓
printer.attributes
        ↓
printerproperties.add_job_option()
        ↓
options.OptionWidget()
        ↓
TypeError

The existing conversion fallback handles ValueError, but None causes TypeError before that fallback can be used.

Fix

Normalize None to the existing empty-value representation at the beginning of OptionWidget().

This allows existing option handling and fallback behavior to process unset values without changing the behavior of valid option values.

The change is intentionally minimal and does not modify the Printer Properties UI logic or CUPS handling.

Tests

Added regression tests covering:

  • A valid numeric CUPS value.
  • The lower supported boundary.
  • A None value with a numeric range.
  • A None value without supported values.
  • A None value with supported choices.
  • Verification that unset values do not mark the option as changed.

Relevant tests pass, along with Python syntax checks and whitespace validation.

Scope

Only the following files are changed:

  • options.py
  • test_options.py

No unrelated behavior or code paths are modified.

@tillkamppeter

Copy link
Copy Markdown
Member

Looks good for me.

@alexpevzner
alexpevzner merged commit c4effbd into master Oct 7, 2026
5 checks passed
@alexpevzner
alexpevzner deleted the fix/printer-properties-none-option branch October 7, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants