diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2018-10-25 11:34:08 -0400 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2018-10-25 11:38:16 -0400 |
| commit | 6966c75947609b5e2dd85aa4cb1725e3e4897e04 (patch) | |
| tree | 7e6434d57e997b3a367e9ddc9e4655bf1563f870 /pkg_resources | |
| parent | 9af3f4208386064dbe5c7f5c9b6724a8bb1e760c (diff) | |
| download | external_python_setuptools-6966c75947609b5e2dd85aa4cb1725e3e4897e04.tar.gz external_python_setuptools-6966c75947609b5e2dd85aa4cb1725e3e4897e04.tar.bz2 external_python_setuptools-6966c75947609b5e2dd85aa4cb1725e3e4897e04.zip | |
Extract patch and its purpose into a specialized function which can be excluded from coverage.
Diffstat (limited to 'pkg_resources')
| -rw-r--r-- | pkg_resources/__init__.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 3cbb5d19..5423af6f 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -2220,15 +2220,18 @@ register_namespace_handler(object, null_ns_handler) def normalize_path(filename): """Normalize a file/dir name for comparison purposes""" - if sys.platform == 'cygwin': - # This results in a call to getcwd() if `filename` is relative. Contrary - # to POSIX 2008 on Cygwin getcwd (3) contains symlink components. Using - # os.path.abspath() works around this limitation. A fix in os.getcwd() - # would probably better, in Cygwin even more so except that this seems - # to be by design... - return os.path.normcase(os.path.realpath(os.path.abspath(filename))) - else: - return os.path.normcase(os.path.realpath(filename)) + return os.path.normcase(os.path.realpath(_cygwin_patch(filename))) + + +def _cygwin_patch(filename): # pragma: nocover + """ + Contrary to POSIX 2008, on Cygwin, getcwd (3) contains + symlink components. Using + os.path.abspath() works around this limitation. A fix in os.getcwd() + would probably better, in Cygwin even more so, except + that this seems to be by design... + """ + return os.path.abspath(filename) if sys.platform == 'cygwin' else filename def _normalize_cached(filename, _cache={}): |
