Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix typo in _get_exe_extensions PATHEXT fallback#1890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 2 commits intogitpython-developers:mainfromEliahKagan:pathext
Apr 2, 2024

Conversation

EliahKagan
Copy link
Member

@EliahKaganEliahKagan commentedMar 31, 2024
edited
Loading

This applies two minor Cygwin-related clarifications, one of which is theoretically a bugfix though it affects conceptually non-public code that is currently not used in a way that could invoke the bug. Some specific details are in commit messages.

The second commit,988d97b, which fixesCOM to.COM in the fallback for thePATHEXT environment variable--whose omission is almost certainly a typo, going back to the function's introduction ine6e23ed (#533)--is theoretically a bugfix. But as noted there, this code is only called when the Python interpreter is a native Windows program, but the function it is a part of is only called when the Python interpreter isnot a native Windows program. (Also, it would be pretty unusual for thegit executable to have a.com extension.)


There are some further changes related to Cygwin detection that may make sense to make in the future, some of which might be best to make after adding relevant tests. The ones that are narrowly related to the change here are that:

  • This value ofPATHEXT here is still unusual, because order matters and this lists.BAT before.COM and.EXE, and because it is missing.CMD, which is part of what a minimal value for it should typically contain. I am uncertain if this strange order is intentional.
  • It may also make sense for the list to include.VBS,.JS,.WS, and.MSC for compatibility with the fallback behavior of the Windowscmd.exe shell whenPATHEXT is unset,which is whatshutil.which does. (I have verified the result of Eryk Sun's debugger check in WinDbg on recent builds of Windows 10 and Windows 11; they are the same.)
  • py_where should really be removed and replaced either with a call toshutil.which, which did not exist at the timepy_where was introduced and would almost certainly have been used at that time if it had--or with other logic that works an altogether different way. Which should be done depends on the intent of the publicGit.is_cygwin_git class method, which is the only code in GitPython that uses theis_cygwin_git function ingit/util.py, for which thepy_where helper exists.

This PR doesn't try to cover any of that. It's really just applying some clarifications that didn't seem like they fit in any other PR that I would do soon.

Regarding the last point aboutGit.is_cygwin_git, if the goal is to detect Cygwin git even on native Windows systems, then the code it uses will have to be significantly revised. That is because currently it always returnsFalse on such systems. In addition, as noted in thepy_where docstring and elsewhere, shell and non-shell path search differ from each other on native Windows, such that neither the nonpublic ad-hocpy_where nor the public generalshutil.which will reliably tell us wheregit is. However, if a path search doesn't need to be done on native Windows, then it can be replaced withshutil.which unless some use has come to depend on (perhaps accidentally introduced) distinctive behavior ofpy_where.

I plan to open an issue about that larger matter, which I am unlikely to work on anytime soon, but that perhaps someone would be interested to take on. (If you know whatGit.is_cygwin_git's semantics are supposed to be, then I can make use of that information in the forthcoming issue, but I can still open it even if its intent is currently uncertain.)

PATHEXT lists file extensions with the ".". In the fallback givenin _get_exe_extensions, the other extensions had this, but ".COM"was listed without the ".". This fixes that.This is very minor because _get_exe_extensions is nonpublic and notcurrently used on native Windows, which is the platform where thePATHEXT fallback code would be used.Specifically, _get_exe_extensions is called only in py_where, whichwhile named with no leading underscore is nonpublic do not being(and never having been) listed in __all__. As its docstring states,it is an implementation detail of is_cygwin_git and not intendedfor any other use. More specifically, is_cygwin_git currentlyimmediately returns False on *native* Windows (even if the gitexecutable GitPython is using is a Cygwin git executable). Only onCygwin, or other systems that are not native Windows, does it tryto check the git executable (by calling its _is_cygwin_git helper,which uses py_where).
@EliahKaganEliahKagan marked this pull request as ready for reviewMarch 31, 2024 21:26
@Byron
Copy link
Member

Thanks a lot for the fix, a great catch!

I don't think it is intentional and would hope it could be set to what makes most sense eventually.

I agree with all the other points as well and look forward to seeing them fixed/improved eventually.

EliahKagan reacted with thumbs up emoji

@ByronByron merged commitf1a7e02 intogitpython-developers:mainApr 2, 2024
@EliahKaganEliahKagan deleted the pathext branchApril 2, 2024 13:36
@Bunggie

This comment was marked as off-topic.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@EliahKagan@Byron@Bunggie

[8]ページ先頭

©2009-2025 Movatter.jp