Tk Source Code

View Ticket
Login
2025-11-03
21:04 • Closed ticket [2a0a8340]: pixel values can report false list lengths plus 6 other changes artifact: ec8a0797 user: jan.nijtmans
21:00
[2a0a834022]: pixel values can report false list lengths check-in: 52666941 user: jan.nijtmans tags: core-9-0-branch
2025-10-31
19:14 • Ticket [2a0a8340] pixel values can report false list lengths status still Open with 4 other changes artifact: fd4ea9d8 user: jan.nijtmans
2025-09-08
16:38 • Ticket [2a0a8340]: 3 changes artifact: 47ca2a2b user: dgp
2025-09-05
16:28 • Ticket [2a0a8340]: 3 changes artifact: fd2775ac user: dgp
16:09 • Ticket [2a0a8340]: 3 changes artifact: ce2324c9 user: dgp
16:03 • Ticket [2a0a8340]: 3 changes artifact: 87e23326 user: dgp
16:01 • Ticket [2a0a8340]: 3 changes artifact: 3ee455f8 user: dgp
15:54 • Ticket [2a0a8340]: 3 changes artifact: 2087de3f user: dgp
15:40 • New ticket [2a0a8340]. artifact: 0ef380a2 user: dgp

Ticket UUID: 2a0a8340227f0ab5de373a59d855dc3d71c88b63
Title: pixel values can report false list lengths
Type: Bug Version: 9.0
Submitter: dgp Created on: 2025-09-05 15:40:38
Subsystem: 27. Objects Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2025-11-03 21:04:50
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2025-11-03 21:04:50
Description:
Tk 8.6 got this right...

% package require Tk
8.6.18
% [button .b] configure -padx "3 m"
% llength [.b cget -padx]
2

Tk 9 gets it wrong:

% package require Tk
9.0.3
% [button .b] configure -padx "3 m"
% llength [.b cget -padx]
1
User Comments: jan.nijtmans added on 2025-11-03 21:04:50:

Simple fix [526669416126d796|here]


jan.nijtmans added on 2025-10-31 19:14:25:

Ping


dgp added on 2025-09-08 16:38:06:
At least on Linux, the Tk test suite does not have
any tests of pixel or mm values that have whitespace
between the number and the units designation.

dgp added on 2025-09-05 16:28:34:
The "mm" Tcl_ObjType suffers from the same bug.

The "pixel" and "mm" types are 95%+ identical.
Is there truly a need for both of them?  Even
if there is, couldn't they be refactored to share
a large fraction of their implementation?

dgp added on 2025-09-05 16:09:44:
A corner case to consider:

% [button .b] configure -padx "0x10 c"
% .b cget -padx
0x10 c

dgp added on 2025-09-05 16:01:05:
The simplest fix is to revert the adoption of the extended
Tcl_ObjType functionality.

An alternative would be to revise the "lengthProc" in the
pixel Tcl_ObjType to report the correct length, taking the
steps to distinguish the length 1 values from the length 2 values.

A mildly incompatible alternative would be to revise
the SetPixelFromAny() function so that values with whitespace
between the number and the units are rejected, so that length 2
list values are no longer accepted as pixel values.

The choice between these options (or another one) would be better
made by Tk developers who can anticipate the effect on other
parts of the Tk code base, and the world of Tk code out there.

dgp added on 2025-09-05 15:54:05:
In Tk 9, the "pixel" Tcl_ObjType is using the abstract list features
of Tcl_ObjType to report that when used as a list, every pixel value
is a list of length 1, which the demo script shows to be false.