| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7de1556 commit 799b9ca
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,21 +31,27 @@ def load_exception_list(file_path): | |||
| 31 | 31 | exception_list.add((file_path, line_number)) | |
| 32 | 32 | return exception_list | |
| 33 | 33 | except FileNotFoundError: | |
| 34 | - print("File not found: %s", file_path) | ||
| 34 | + print(f"File not found: {file_path}") | ||
| 35 | 35 | return set() | |
| 36 | 36 | except Exception as e: | |
| 37 | - print("Error loading exception list: %s", e) | ||
| 37 | + print(f"Error loading exception list: {e}") | ||
| 38 | 38 | return set() | |
| 39 | 39 | ||
| 40 | 40 | ||
| 41 | - def check_exception_against_list(exception_list, exc_traceback): | ||
| 42 | - """Check if the exception traceback matches any entry in the exception list.""" | ||
| 41 | + def match_exception_with_traceback(exception_list, exc_traceback): | ||
| 42 | + """Match exception traceback with the entries in the exception list.""" | ||
| 43 | 43 | for filename, lineno, _, _ in traceback.extract_tb(exc_traceback): | |
| 44 | - if (filename, lineno) in exception_list: | ||
| 45 | - return True | ||
| 44 | + for file_pattern, line_pattern in exception_list: | ||
| 45 | + if re.fullmatch(file_pattern, filename) and re.fullmatch(line_pattern, str(lineno)): | ||
| 46 | + return True | ||
| 46 | 47 | return False | |
| 47 | 48 | ||
| 48 | 49 | ||
| 50 | + def check_exception_against_list(exception_list, exc_traceback): | ||
| 51 | + """Check if the exception traceback matches any entry in the exception list.""" | ||
| 52 | + return match_exception_with_traceback(exception_list, exc_traceback) | ||
| 53 | + | ||
| 54 | + | ||
| 49 | 55 | if not sys.warnoptions: # pragma: no cover | |
| 50 | 56 | # The warnings filter below can be overridden by passing the -W option | |
| 51 | 57 | # to the Python interpreter command line or setting the `PYTHONWARNINGS` environment variable. | |
@@ -128,10 +134,8 @@ def TestOneInput(data): | |||
| 128 | 134 | exc_traceback = e.__traceback__ | |
| 129 | 135 | exception_list = load_exception_list(os.path.join(bundle_dir, "explicit-exceptions-list.txt")) | |
| 130 | 136 | if check_exception_against_list(exception_list, exc_traceback): | |
| 131 | - print("Exception matches an entry in the exception list.") | ||
| 132 | 137 | return -1 | |
| 133 | 138 | else: | |
| 134 | - print("Exception does not match any entry in the exception list.") | ||
| 135 | 139 | raise e | |
| 136 | 140 | ||
| 137 | 141 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments