Skip to content

Commit e77036a

Browse files
authored
Add verification of log path in DEFAULT_BZ_LOG
Use explicit try-except to ensure that the expected exception is raised so the subsequent operations are terminated just in time.
1 parent 0194ec7 commit e77036a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

bugzilla/_mi.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@ def setup_logging():
205205
Avoid interfering with the contents in
206206
`stderr` and `stdout` as much as possible
207207
"""
208+
try:
209+
__F = open(DEFAULT_BZ_LOG, mode="ab")
210+
except Exception as __E:
211+
raise RuntimeError("CANNOT create instance of logging.FileHandler "
212+
"with {}".format(repr(DEFAULT_BZ_LOG))) from __E
213+
else:
214+
__F.close()
208215
handler = logging.FileHandler(DEFAULT_BZ_LOG, mode="a", encoding="utf-8", delay=False)
209216
handler.setFormatter(logging.Formatter(
210217
"%(asctime)s,%(msecs)d %(filename)s:%(lineno)d %(levelname)s: %(message)s",
@@ -660,4 +667,4 @@ def main(unittest_bz_instance=None):
660667

661668

662669
def mi():
663-
main()
670+
main()

0 commit comments

Comments
 (0)