gh-83653: Do not save a blank int entry in IDLE Settings
Blanking an integer entry wrote an empty string to the config file, which
caused an "invalid int value" warning when it was read back.
Co-authored-by: Cheryl Sabella <cheryl.sabella@gmail.com>
"Return default callback function to add values to changes instance."
def default_callback(*params):
"Add config values to changes instance."
- changes.add_option(*config, var.get())
+ value = var.get()
+ # A blanked int entry is an empty string; do not save it as an
+ # invalid config value (gh-83653).
+ if value != '':
+ changes.add_option(*config, value)
return default_callback
def attach(self):
self.assertEqual(changes['main']['section']['option'], '42')
changes.clear()
+ # gh-83653: a blank int entry is not saved as bad config data.
+ sv = StringVar(root)
+ cb = self.tracers.make_callback(sv, ('main', 'section', 'option'))
+ sv.set('')
+ cb()
+ self.assertNotIn('section', changes['main'])
+ sv.set('5')
+ cb()
+ self.assertEqual(changes['main']['section']['option'], '5')
+ changes.clear()
+
def test_attach_detach(self):
tr = self.tracers
iv = tr.add(self.iv, self.var_changed_increment)
--- /dev/null
+Blanking an integer entry in IDLE's Settings dialog, such as "Auto squeeze
+min lines", no longer saves an empty string as an invalid configuration
+value.