Tk Source Code

View Ticket
Login
Ticket UUID: 853414
Title: Document undefined bindings
Type: Bug Version: obsolete: 8.5a0
Submitter: nobody Created on: 2003-12-03 17:00:14
Subsystem: 01. Bindings Assigned To: jenglish
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-10-22 18:49:22
Resolution: Fixed Closed By: nemethi
    Closed on: 2026-10-22 18:49:22
Description:
The `bind` man page has always said, "Some of the
substitutions are only valid for certain types of
events; if they are used for other types of events the
value substituted is undefined."  Donal has been
tightening this up lately (8.4?), so that now invalid
substitutions are guaranteed to yield {???} (true?).  I
ask that we upgrade the documentation to reflect this.

Donal believes Joe English is likely to be in a good
position to review the idea.
User Comments: nemethi (claiming to be Csaba Nemethi) added on 2026-10-22 18:49:22:

Serhiy, many thanks! Merged into main, core-9-0-branch, and core-8-6-branch by commits [fb166f9f], [b0a2037b], and [e5120791].


serhiy.storchaka added on 2026-09-23 11:47:45:

An invalid substitution yields the literal string ??: ExpandPercents() in generic/tkBind.c initializes the replacement to ?? and only overwrites it when the event carries the requested field. Documentation is updated in doc-undefined-substitutions.

On throwing an error at bind time: that would break Tkinter, which appends a fixed list of 19 substitutions (Misc._subst_format: %# %b %f %h %k %s %t %w %x %y %A %E %K %N %W %T %X %Y %D) to every binding, whatever the event type, and whose _substitute() deliberately tolerates the result: "Tk changed behavior in 8.4.2, returning "??" rather more often". Perl/Tk and Ruby/Tk bind the same way.


dkf added on 2003-12-04 16:16:34:
Logged In: YES 
user_id=79902

FWIW, in the longer term I'd love to parse events at [bind]
time and throw an error if they have invalid substitutions.
 That's a Tk9 thing at the earliest though.