[issue40536] Addition of a "list of available time zones" function to zoneinfo

STINNER Victor report at bugs.python.org
Mon May 18 08:47:57 EDT 2020


STINNER Victor <vstinner at python.org> added the comment:

def valid_key(fpath):
        try:
            with open(fpath, "rb") as f:
                return f.read(4) == b"TZif"
        except Exception:  # pragma: nocover
            return False


Why not only catching "except OSError:" rather than any exception?

Or even "except (FileNotFoundError, PermissionError):" if you want to be pedantic :-p

----------
nosy: +vstinner

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40536>
_______________________________________


More information about the Python-bugs-list mailing list