Handle an import error according to the on_error policy.
(on_error, modinfo, exc, *, warn_stacklevel)
| 230 | # |
| 231 | |
| 232 | def _handle_import_error(on_error, modinfo, exc, *, warn_stacklevel): |
| 233 | """Handle an import error according to the on_error policy.""" |
| 234 | match on_error: |
| 235 | case 'fail': |
| 236 | raise |
| 237 | case 'warn': |
| 238 | warnings.warn( |
| 239 | f"Failed to preload {modinfo}: {exc}", |
| 240 | ImportWarning, |
| 241 | stacklevel=warn_stacklevel + 1 |
| 242 | ) |
| 243 | case 'ignore': |
| 244 | pass |
| 245 | |
| 246 | |
| 247 | def _handle_preload(preload, main_path=None, sys_path=None, sys_argv=None, |
no test coverage detected
searching dependent graphs…