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

Casey Duncan casey@zope.com
Thu, 18 Jul 2002 09:20:56 -0400


My guess would be that it would get an OSError possible IndexError, but I=
'm=20
not sure the logic in just setting the mtime to null and continuing.=20
especially since it will likely just try and fail to open the file a few=20
lines later...

This could actually be simplified to:

try:=20
    mtime =3D os.path.getmtime(self.filename)
except OSError:=20
    mtime =3D 0

-Casey

On Wednesday 17 July 2002 07:08 pm, Steve Alexander wrote:
> lib/python/Products/PageTemplateFile.py, line 110, method _cook_check
>=20
>          try:    mtime=3Dos.stat(self.filename)[8]
>          except: mtime=3D0
>=20
>=20
> I've just spent an hour or so tracking down an awkward bug in some=20
> unit-tests. The true error was being hidden by this bare except.
>=20
> I'd change it, and commit the change, except that I don't know what it=20
> is supposed to be catching. Any hints?
>=20
> Actually, I'd rather just remove the try: except: and let os.stat fail=20
> if it is going to fail. Any objections?
>=20
> (of course there will be... even bare excepts were put there for some=20
> reason...)
>=20
> --
> Steve Alexander