summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/configHandler.py
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2012-12-24 11:15:43 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2012-12-24 11:15:43 (GMT)
commit8a495a48a53369120e7ca3b57efe9a07745ea067 (patch)
treeeb0f056072f7b3890c7deaf2237eed1e2f8ea6b4 /Lib/idlelib/configHandler.py
parent159bb53765c895abb701d20881f13468484a9dba (diff)
downloadcpython-8a495a48a53369120e7ca3b57efe9a07745ea067.zip
cpython-8a495a48a53369120e7ca3b57efe9a07745ea067.tar.gz
cpython-8a495a48a53369120e7ca3b57efe9a07745ea067.tar.bz2
Issue #16511: Use default IDLE width and height if config param is not valid.
Patch Serhiy Storchaka.
Diffstat (limited to 'Lib/idlelib/configHandler.py')
-rw-r--r--Lib/idlelib/configHandler.py51
1 files changed, 33 insertions, 18 deletions
diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py
index da92726..e22ceb0 100644
--- a/Lib/idlelib/configHandler.py
+++ b/Lib/idlelib/configHandler.py
@@ -237,24 +237,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.