[patch] verbose mode broken in fstest.py

Bug #475996 reported by Andrew Daugherity
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ZODB
Fix Released
Undecided
Unassigned

Bug Description

[Note: I am using whatever version of ZODB that ships with Zope 2.10.7, but this bug _appears_ to still be in trunk, assuming http://svn.zope.org/ZODB/trunk/src/ZODB/scripts/ is the correct SVN repo.]

The verbose option '-v' to fstest.py no longer works (it previously did, in the version shipped with Zope 2.9). It now causes a Python error:
====
andrew@zeo:~> /opt/zope210/bin/fstest.py.orig -v /tmp/Session.fs
Traceback (most recent call last):
  File "/opt/zope210/bin/fstest.py.orig", line 228, in ?
    main()
  File "/opt/zope210/bin/fstest.py.orig", line 215, in main
    VERBOSE = VERBOSE + 1
UnboundLocalError: local variable 'VERBOSE' referenced before assignment
====

This bug was introduced by r71254, which added the def main(): wrapper. The problem is that it is attempting to use a local variable VERBOSE in the assignment statement, rather than the global variable. This is fixed by a simple patch that declares VERBOSE to be a global variable:
====
--- fstest.py.orig 2009-11-05 17:48:17.000000000 -0600
+++ fstest.py 2009-11-05 16:01:58.000000000 -0600
@@ -206,6 +206,7 @@
 def main():
     import getopt

+ global VERBOSE
     try:
         opts, args = getopt.getopt(sys.argv[1:], 'v')
         if len(args) != 1:
====

With the global variable declaration added, it now works correctly:
====
andrew@zeo:~> /opt/zope210/bin/fstest.py -v /tmp/Session.fs
         4: transaction tid 0x0379d23cb63b7e11 #0
      1111: transaction tid 0x037bd337f5194a11 #1
      1960: transaction tid 0x0381a63f44093266 #2
      2989: transaction tid 0x0381a63f56b5baaa #3
      3428: transaction tid 0x0381a641202d0999 #4
      3866: transaction tid 0x0381a642201f6e55 #5
      4187: transaction tid 0x0381a6424c0e0199 #6
etc.
====

Revision history for this message
Jim Fulton (jim-zope) wrote :

Thanks!

The fix will appear in 3.10b7.

Changed in zodb:
status: New → Fix Committed
Changed in zodb:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.