|
34 | 34 | from collections.abc import Iterable
|
35 | 35 | from glob import glob
|
36 | 36 | from sysconfig import get_path
|
37 |
| -from typing import TYPE_CHECKING |
| 37 | +from typing import TYPE_CHECKING, Callable, TypeVar |
38 | 38 |
|
39 | 39 | from jaraco.text import yield_lines
|
40 | 40 |
|
|
89 | 89 | 'get_exe_prefixes',
|
90 | 90 | ]
|
91 | 91 |
|
| 92 | +_T = TypeVar("_T") |
| 93 | + |
92 | 94 |
|
93 | 95 | def is_64bit():
|
94 | 96 | return struct.calcsize("P") == 8
|
@@ -1786,13 +1788,14 @@ def _first_line_re():
|
1786 | 1788 | return re.compile(first_line_re.pattern.decode())
|
1787 | 1789 |
|
1788 | 1790 |
|
1789 |
| -def auto_chmod(func, arg, exc): |
| 1791 | +# Must match shutil._OnExcCallback |
| 1792 | +def auto_chmod(func: Callable[..., _T], arg: str, exc: BaseException) -> _T: |
| 1793 | + """shutils onexc callback to automatically call chmod for certain functions.""" |
| 1794 | + # Only retry for scenarios known to have an issue |
1790 | 1795 | if func in [os.unlink, os.remove] and os.name == 'nt':
|
1791 | 1796 | chmod(arg, stat.S_IWRITE)
|
1792 | 1797 | return func(arg)
|
1793 |
| - et, ev, _ = sys.exc_info() |
1794 |
| - # TODO: This code doesn't make sense. What is it trying to do? |
1795 |
| - raise (ev[0], ev[1] + (" %s %s" % (func, arg))) # pyright: ignore[reportOptionalSubscript, reportIndexIssue] |
| 1798 | + raise exc |
1796 | 1799 |
|
1797 | 1800 |
|
1798 | 1801 | def update_dist_caches(dist_path, fix_zipimporter_caches):
|
|
0 commit comments