|
11 | 11 | import sys
|
12 | 12 | import warnings
|
13 | 13 | from _frozen_importlib_external import _NamespacePath
|
| 14 | +from collections.abc import Generator, Sequence |
14 | 15 | from contextlib import contextmanager
|
15 | 16 | from pathlib import Path
|
16 |
| -from typing import Any, Generator, NewType, Sequence |
| 17 | +from typing import Any, NewType |
17 | 18 | from urllib.parse import (
|
18 | 19 | SplitResult,
|
19 | 20 | quote,
|
@@ -378,17 +379,9 @@ def filefind(filename: str, path_dirs: Sequence[str]) -> str:
|
378 | 379 | # os.path.abspath resolves '..', but Path.absolute() doesn't
|
379 | 380 | # Path.resolve() does, but traverses symlinks, which we don't want
|
380 | 381 | test_path = Path(os.path.abspath(test_path))
|
381 |
| - if sys.version_info >= (3, 9): |
382 |
| - if not test_path.is_relative_to(path): |
383 |
| - # points outside root, e.g. via `filename='../foo'` |
384 |
| - continue |
385 |
| - else: |
386 |
| - # is_relative_to is new in 3.9 |
387 |
| - try: |
388 |
| - test_path.relative_to(path) |
389 |
| - except ValueError: |
390 |
| - # points outside root, e.g. via `filename='../foo'` |
391 |
| - continue |
| 382 | + if not test_path.is_relative_to(path): |
| 383 | + # points outside root, e.g. via `filename='../foo'` |
| 384 | + continue |
392 | 385 | # make sure we don't call is_file before we know it's a file within a prefix
|
393 | 386 | # GHSA-hrw6-wg82-cm62 - can leak password hash on windows.
|
394 | 387 | if test_path.is_file():
|
|
0 commit comments