Terry J. Reedy <tjre...@udel.edu> added the comment: (This is behavior, not crash issue, as the latter is when there is no traceback.)
The editor code was added 3 years ago in #37929, PR-15452, to correct using the configured char width after font and window size changes make that invalid. It is based on https://www.tcl.tk/man/tcl8.6/TkCmd/text.html#M21 "If the font does not have a uniform width then the width of the character “0” [zero] is used in translating from character units to screen units." The implies that said char width is non-zero. It would seem like a font bug if not. This is first report I know of where width is 0. The current code implements this as zero_char_width = \ Font(text, font=text.cget('font')).measure('0') Matej, what OS and font gives this error? Please run the following, also uploaded, with the offending font, replacing the name I used. import tkinter as tk from tkinter.font import Font r = tk.Tk() t = tk.Text(r, font=('Source Code Pro', 10, 'normal')) t.pack() s = '0oO !*}' t.insert('1.0', s) # Only to check that all above is valid. for c in s: print(Font(t, font=t['font']).measure(c)) For fixed 10 pitch Source Code Pro, all widths are 8. --- We could, of course, catch ZeroDivisionError, but when then? This is why I want to know what OS, font, and a test with multiple characters. On possibility is to check whenever font is set, but still, what then? ---------- nosy: +taleinat type: crash -> behavior versions: +Python 3.11 -Python 3.8 Added file: https://bugs.python.org/file50507/tem.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46146> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com