[Zope-dev] bad bare except in PageTemplateFile.py

Steve Alexander steve@cat-box.net
Thu, 18 Jul 2002 15:24:42 +0100


Steve Alexander wrote:
> Shane Hathaway wrote:
> 
>>
>> I vaguely recall having a similar discussion with someone regarding 
>> DTMLFile, and we decided it had to ignore missing files, but I don't 
>> remember why.
> 
> 
> Darn... that'll be just the reason I'm looking for!
> 
> 
>> Also, the open() call just below that line will raise an equivalent 
>> exception.
> 
> 
> For some reason, the code was not getting there when I came across this 
> problem. I guess this 'if' expression must have evaluated true.
> 
>     if hasattr(self, '_v_program') and mtime == self._v_last_read:
>         return
> 
> I'm not sure why it would have done so though.

Now I know. _v_program is defined in the PageTemplate base class as None.
So, the if statement should be

      if self._v_program and mtime == self._v_last_read:
          return

If I make that change, then I get an OSError as expected.

So, I'll change the bare except: to catch OSError, and change the if 
statement as described. Great.

--
Steve Alexander