summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2001-07-10 21:48:51 (GMT)
committerBarry Warsaw <barry@python.org>2001-07-10 21:48:51 (GMT)
commitffa926d77e530a87703c0547bde76cc59e8e963e (patch)
tree654bc5afb1777497c805f651ae95e9b450bd3492
parent698c14936a2f933c709ea3b412af16478ba8594d (diff)
downloadcpython-ffa926d77e530a87703c0547bde76cc59e8e963e.zip
cpython-ffa926d77e530a87703c0547bde76cc59e8e963e.tar.gz
cpython-ffa926d77e530a87703c0547bde76cc59e8e963e.tar.bz2
__init__(), save_views(): Catch ValueError along with IOError and
EOFError so any failures in unmarshalling are just ignored. Use print>> instead of sys.stderr.write().
-rw-r--r--Tools/pynche/Switchboard.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/Tools/pynche/Switchboard.py b/Tools/pynche/Switchboard.py
index f67a1a9..0ad7c63 100644
--- a/Tools/pynche/Switchboard.py
+++ b/Tools/pynche/Switchboard.py
@@ -45,6 +45,8 @@ import sys
from types import DictType
import marshal
+
+
class Switchboard:
def __init__(self, initfile):
self.__initfile = initfile
@@ -63,11 +65,10 @@ class Switchboard:
fp = open(initfile)
self.__optiondb = marshal.load(fp)
if type(self.__optiondb) <> DictType:
- sys.stderr.write(
- 'Problem reading options from file: %s\n' %
- initfile)
+ print >> sys.stderr, \
+ 'Problem reading options from file:', initfile
self.__optiondb = {}
- except (IOError, EOFError):
+ except (IOError, EOFError, ValueError):
pass
finally:
if fp:
@@ -118,8 +119,8 @@ class Switchboard:
try:
fp = open(self.__initfile, 'w')
except IOError:
- sys.stderr.write('Cannot write options to file: %s\n' %
- self.__initfile)
+ print >> sys.stderr, 'Cannot write options to file:', \
+ self.__initfile
else:
marshal.dump(self.__optiondb, fp)
finally: