Use normalised lower case paths and filenames for logging and debugging exclusions

- Correct case sensitivity for path comparisons are not important for this use case
This commit is contained in:
MoojMidge 2025-07-03 16:13:35 +09:00
parent 277923f9d4
commit 97d27192e3
2 changed files with 9 additions and 7 deletions

View file

@ -16,7 +16,7 @@ from atexit import register as atexit_register
from cProfile import Profile
from functools import wraps
from os import times as os_times
from os.path import normcase
from os.path import normpath
from pstats import Stats
from traceback import extract_stack, format_list
from weakref import ref
@ -335,7 +335,7 @@ class ExecTimeout(object):
if self._timed_out:
raise RuntimeError(self._get_msg())
else:
filename = normcase(frame.f_code.co_filename)
filename = normpath(frame.f_code.co_filename).lower()
skip_event = (
filename == self.src_file
or (self._skip_paths
@ -364,4 +364,6 @@ class ExecTimeout(object):
).format(event=event, stack_trace=stack_trace)
ExecTimeout.src_file = normcase(ExecTimeout.__init__.__code__.co_filename)
ExecTimeout.src_file = normpath(
ExecTimeout.__init__.__code__.co_filename
).lower()

View file

@ -11,7 +11,7 @@
from __future__ import absolute_import, division, unicode_literals
import logging
from os.path import normcase
from os.path import normpath
from sys import exc_info as sys_exc_info
from traceback import extract_stack, format_list
@ -402,13 +402,13 @@ def getLogger(name=None):
_srcfiles = {
normcase(getLogger.__code__.co_filename),
normcase(logging.getLogger.__code__.co_filename),
normpath(getLogger.__code__.co_filename).lower(),
normpath(logging.getLogger.__code__.co_filename).lower(),
}
def check_frame(frame, stacklevel=None, skip_paths=None):
filename = normcase(frame.f_code.co_filename)
filename = normpath(frame.f_code.co_filename).lower()
is_internal = (
filename in _srcfiles
or ('importlib' in filename and '_bootstrap' in filename)