[mod_python] servlet possible little bug?

Daniel Popowich dpopowich at comcast.net
Tue Aug 3 10:25:12 EDT 2004


Congratulations!  You found the first servlet bug!!  I will put out a
new package, but in the meantime you can apply the patch attached below.

The problem is with the parens around two assert statements which make
the assertion tests always be a non-empty tuple, that is, true.  Duh.
(I've been trying to think how that happened as I know I extensively
tested all the assertions in my code and the only thing I can think of
is that I placed the parens there just before releasing as I was doing
a formatting sweep of the code: I tend to format long lines using
parens instead of backslash-newline.  *sigh*)

Thanks for finding this.

Daniel
---------------------------------------------------
| Mod_python Servlets                             |
| http://home.comcast.net/~d.popowich/mpservlets/ |
---------------------------------------------------

-------------- next part --------------
*** servlet.py  2004/05/27 19:34:14     1.9
--- servlet.py  2004/08/03 13:07:00
*************** class Servlet:
*** 275,283 ****
          assert NAME.match(name), ('Argument name must be a legal '
                                    'python identifier')
  
!         assert (isinstance(default, (list, dict, str)),
!                 ('Argument default value must be a string, '
!                  'list or dict (or subclass thereof)'))
          
          if isinstance(default, list):
              for i in default:
--- 275,283 ----
          assert NAME.match(name), ('Argument name must be a legal '
                                    'python identifier')
  
!         assert isinstance(default, (list, dict, str)), \
!                ('Argument default value must be a string, '
!                 'list or dict (or subclass thereof)')
          
          if isinstance(default, list):
              for i in default:
*************** class Servlet:
*** 287,295 ****
              for k,v in default.iteritems():
                  assert type(k) is str, ('Default keys of dicts must '
                                          'be strings')
!                 assert (isinstance(v, (str, list)),
!                         ('Default values of dicts must have values of lists '
!                          'or strings'))
                          
          assert conv is None or callable(conv), ('Argument conversion must '
                                                  'be None or callable')
--- 287,295 ----
              for k,v in default.iteritems():
                  assert type(k) is str, ('Default keys of dicts must '
                                          'be strings')
!                 assert isinstance(v, (str, list)), \
!                        ('Default values of dicts must have values of lists '
!                         'or strings')
                          
          assert conv is None or callable(conv), ('Argument conversion must '
                                                  'be None or callable')


More information about the Mod_python mailing list