Commit f305bd3e authored by Amaury Forgeot d'Arc's avatar Amaury Forgeot d'Arc

Issue 2665: On Windows, sys.stderr does not contain a valid file when running without a console.

It seems to work, but will fail at the first flush.

This causes IDLE to silently crash when too many warnings are printed.

Backport of r62448.
parent 0f1653e9
What's New in IDLE 1.2.3c1? What's New in IDLE 1.2.3c1?
========================= ===========================
*Release date: XX-XXX-2008* *Release date: XX-XXX-2008*
- Issue #2665: On Windows, an IDLE installation upgraded from an old version
would not start if a custom theme was defined.
What's New in IDLE 1.2.2? What's New in IDLE 1.2.2?
========================= =========================
......
...@@ -207,7 +207,10 @@ class IdleConf: ...@@ -207,7 +207,10 @@ class IdleConf:
if not os.path.exists(userDir): if not os.path.exists(userDir):
warn = ('\n Warning: os.path.expanduser("~") points to\n '+ warn = ('\n Warning: os.path.expanduser("~") points to\n '+
userDir+',\n but the path does not exist.\n') userDir+',\n but the path does not exist.\n')
sys.stderr.write(warn) try:
sys.stderr.write(warn)
except IOError:
pass
userDir = '~' userDir = '~'
if userDir == "~": # still no path to home! if userDir == "~": # still no path to home!
# traditionally IDLE has defaulted to os.getcwd(), is this adequate? # traditionally IDLE has defaulted to os.getcwd(), is this adequate?
...@@ -248,7 +251,10 @@ class IdleConf: ...@@ -248,7 +251,10 @@ class IdleConf:
' from section %r.\n' ' from section %r.\n'
' returning default value: %r\n' % ' returning default value: %r\n' %
(option, section, default)) (option, section, default))
sys.stderr.write(warning) try:
sys.stderr.write(warning)
except IOError:
pass
return default return default
def SetOption(self, configType, section, option, value): def SetOption(self, configType, section, option, value):
...@@ -357,7 +363,10 @@ class IdleConf: ...@@ -357,7 +363,10 @@ class IdleConf:
'\n from theme %r.\n' '\n from theme %r.\n'
' returning default value: %r\n' % ' returning default value: %r\n' %
(element, themeName, theme[element])) (element, themeName, theme[element]))
sys.stderr.write(warning) try:
sys.stderr.write(warning)
except IOError:
pass
colour=cfgParser.Get(themeName,element,default=theme[element]) colour=cfgParser.Get(themeName,element,default=theme[element])
theme[element]=colour theme[element]=colour
return theme return theme
...@@ -611,7 +620,10 @@ class IdleConf: ...@@ -611,7 +620,10 @@ class IdleConf:
'\n from key set %r.\n' '\n from key set %r.\n'
' returning default value: %r\n' % ' returning default value: %r\n' %
(event, keySetName, keyBindings[event])) (event, keySetName, keyBindings[event]))
sys.stderr.write(warning) try:
sys.stderr.write(warning)
except IOError:
pass
return keyBindings return keyBindings
def GetExtraHelpSourceList(self,configSet): def GetExtraHelpSourceList(self,configSet):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment