[Mailman-Developers] no such file config.pck updating to 2.1b1

Barry A. Warsaw barry@zope.com
Fri, 5 Apr 2002 09:43:53 -0500


>>>>> "GK" == Georg Koch <gorg@sun31.imbi.uni-freiburg.de> writes:

    GK> but I cannot, because MailList.py stops with an uncatched
    GK> exception first. __load is called from load like this:
    |         for file in (pfile, plast, dfile, dlast):
    |             dict, e = self.__load(file)
    GK> so in __load the mtime of non-existing config.pck is asked and
    GK> yields the exception which is not handled.

Feh, I'm a big dummy.  Please try the attached patch.

-Barry

Index: MailList.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/MailList.py,v
retrieving revision 2.67
retrieving revision 2.68
diff -u -r2.67 -r2.68
--- MailList.py	1 Apr 2002 16:31:25 -0000	2.67
+++ MailList.py	5 Apr 2002 14:43:28 -0000	2.68
@@ -493,14 +493,21 @@
             loadfunc = cPickle.load
         else:
             assert 0, 'Bad database file name'
-        mtime = os.path.getmtime(dbfile)
-        if mtime <= self.__timestamp:
-            # File is not newer
-            return None, None
         try:
+            # Check the mod time of the file first.  If it matches our
+            # timestamp, then the state hasn't change since the last time we
+            # loaded it.  Otherwise open the file for loading, below.  If the
+            # file doesn't exist, we'll get an EnvironmentError with errno set
+            # to ENOENT (EnvironmentError is the base class of IOError and
+            # OSError).
+            mtime = os.path.getmtime(dbfile)
+            if mtime <= self.__timestamp:
+                # File is not newer
+                return None, None
             fp = open(dbfile)
-        except IOError, e:
+        except EnvironmentError, e:
             if e.errno <> errno.ENOENT: raise
+            # The file doesn't exist yet
             return None, e
         try:
             try: