[Zodb-checkins] SVN: ZODB/trunk/src/ZEO/ Fixed a bad-magic-number exception message .

Jim Fulton jim at zope.com
Wed Nov 19 18:25:49 EST 2008


Log message for revision 93149:
  Fixed a bad-magic-number exception message .
  
  (Thanks to Patrick Strawderman for pointing this out and providing an
  initial fix.)
  

Changed:
  U   ZODB/trunk/src/ZEO/cache.py
  U   ZODB/trunk/src/ZEO/tests/test_cache.py

-=-
Modified: ZODB/trunk/src/ZEO/cache.py
===================================================================
--- ZODB/trunk/src/ZEO/cache.py	2008-11-19 22:10:04 UTC (rev 93148)
+++ ZODB/trunk/src/ZEO/cache.py	2008-11-19 23:25:48 UTC (rev 93149)
@@ -242,7 +242,8 @@
         write = f.write
         seek(0)
         if read(4) != magic:
-            raise ValueError("unexpected magic number: %r" % magic)
+            seek(0)
+            raise ValueError("unexpected magic number: %r" % read(4))
         self.tid = read(8)
         if len(self.tid) != 8:
             raise ValueError("cache file too small -- no tid at start")

Modified: ZODB/trunk/src/ZEO/tests/test_cache.py
===================================================================
--- ZODB/trunk/src/ZEO/tests/test_cache.py	2008-11-19 22:10:04 UTC (rev 93148)
+++ ZODB/trunk/src/ZEO/tests/test_cache.py	2008-11-19 23:25:48 UTC (rev 93149)
@@ -481,6 +481,14 @@
     >>> logger.removeHandler(handler)
 
     >>> cache.close()
+    """,
+    bad_magic_number =
+    r"""
+    >>> open('cache', 'w').write("Hi world!")
+    >>> cache = ZEO.cache.ClientCache('cache', 1000)
+    Traceback (most recent call last):
+    ...
+    ValueError: unexpected magic number: 'Hi w'
     """
     )
 



More information about the Zodb-checkins mailing list