mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #16511: Use default IDLE width and height if config param is not valid.
Patch Serhiy Storchaka.
This commit is contained in:
commit
7174f0883c
5 changed files with 65 additions and 35 deletions
|
@ -238,24 +238,39 @@ class IdleConf:
|
|||
printed to stderr.
|
||||
|
||||
"""
|
||||
if self.userCfg[configType].has_option(section,option):
|
||||
return self.userCfg[configType].Get(section, option,
|
||||
type=type, raw=raw)
|
||||
elif self.defaultCfg[configType].has_option(section,option):
|
||||
return self.defaultCfg[configType].Get(section, option,
|
||||
type=type, raw=raw)
|
||||
else: #returning default, print warning
|
||||
if warn_on_default:
|
||||
warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n'
|
||||
' problem retrieving configuration option %r\n'
|
||||
' from section %r.\n'
|
||||
' returning default value: %r\n' %
|
||||
(option, section, default))
|
||||
try:
|
||||
sys.stderr.write(warning)
|
||||
except IOError:
|
||||
pass
|
||||
return default
|
||||
try:
|
||||
if self.userCfg[configType].has_option(section,option):
|
||||
return self.userCfg[configType].Get(section, option,
|
||||
type=type, raw=raw)
|
||||
except ValueError:
|
||||
warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n'
|
||||
' invalid %r value for configuration option %r\n'
|
||||
' from section %r: %r\n' %
|
||||
(type, option, section,
|
||||
self.userCfg[configType].Get(section, option,
|
||||
raw=raw)))
|
||||
try:
|
||||
sys.stderr.write(warning)
|
||||
except IOError:
|
||||
pass
|
||||
try:
|
||||
if self.defaultCfg[configType].has_option(section,option):
|
||||
return self.defaultCfg[configType].Get(section, option,
|
||||
type=type, raw=raw)
|
||||
except ValueError:
|
||||
pass
|
||||
#returning default, print warning
|
||||
if warn_on_default:
|
||||
warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n'
|
||||
' problem retrieving configuration option %r\n'
|
||||
' from section %r.\n'
|
||||
' returning default value: %r\n' %
|
||||
(option, section, default))
|
||||
try:
|
||||
sys.stderr.write(warning)
|
||||
except IOError:
|
||||
pass
|
||||
return default
|
||||
|
||||
def SetOption(self, configType, section, option, value):
|
||||
"""In user's config file, set section's option to value.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue