René's URL Explorer Experiment


Title: `USE_SHELL = True` not needed since 2.0.8 but still suggested for Windows · Issue #1781 · gitpython-developers/GitPython · GitHub

Open Graph Title: `USE_SHELL = True` not needed since 2.0.8 but still suggested for Windows · Issue #1781 · gitpython-developers/GitPython

X Title: `USE_SHELL = True` not needed since 2.0.8 but still suggested for Windows · Issue #1781 · gitpython-developers/GitPython

Description: The Git.USE_SHELL attribute is currently presented this way: GitPython/git/cmd.py Lines 281 to 285 in d986a59 # If True, a shell will be used when executing git commands. # This should only be desirable on Windows, see https://github.com...

Open Graph Description: The Git.USE_SHELL attribute is currently presented this way: GitPython/git/cmd.py Lines 281 to 285 in d986a59 # If True, a shell will be used when executing git commands. # This should only be desi...

X Description: The Git.USE_SHELL attribute is currently presented this way: GitPython/git/cmd.py Lines 281 to 285 in d986a59 # If True, a shell will be used when executing git commands. # This should only be desi...

Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/1781

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`USE_SHELL = True` not needed since 2.0.8 but still suggested for Windows","articleBody":"The `Git.USE_SHELL` attribute is currently presented this way:\r\n\r\nhttps://github.com/gitpython-developers/GitPython/blob/d986a59467e586afb815d71845f29b605b756cdf/git/cmd.py#L281-L285\r\n\r\nI believe this encourages developers writing graphical Windows applications that use GitPython to set `USE_SHELL = True`, or to retain this in their code from when it may have been added in the past, at a time that it worked around a problem.\r\n\r\nHowever, this is no longer necessary, even in that specific use case on Windows. **The problem of console windows being created for GitPython's `git` subprocesses in graphical Windows applications was solved back in 2016**, in 0d93908 (#469), by passing the `CREATE_NO_WINDOW` [process creation flag](https://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags). How and where that is expressed has changed over time, but the current code defines `PROC_CREATIONFLAGS` (which it passes to `creationflags` in calls to `Popen`):\r\n\r\nhttps://github.com/gitpython-developers/GitPython/blob/d986a59467e586afb815d71845f29b605b756cdf/git/cmd.py#L231-L236\r\n\r\nThat change to passing `CREATE_NO_WINDOW` was not the main motivation behind #469, and it appears to some extent to have escaped notice, not having made it into the manually written changelogs of any version of GitPython. The recommendation to set `USE_SHELL` to `True` had previously been entered into the changelog in 1c2dd54 for 0.3.7, when it was made no longer the default on Windows, as it had been since 3f277ba (#126). In contrast, it was no longer necessary (nor useful) to do this since [2.0.8](https://github.com/gitpython-developers/GitPython/blob/main/doc/source/changes.rst#208---features-and-bugfixes), the first release after #469 was merged, but that change was never noted.\r\n\r\nUsing `shell=True` as a default is undesirable at least in the typical case that `Git.execute` is called indirectly through dynamic methods, because it is not typically feasible to account for the effect of shell expansions. The `Git` class is used in GitPython, and documented for use, in ways that do not account for characters with special meaning to the shell being present in text supplied as paths, branch and tag names, and so forth.\r\n\r\nFor that reason, combined with the better approach to #126 that came in with #469, comments or associated documentation for `Git.USE_SHELL` should no longer recommend its use in any likely scenarios, and should even caution against its use in the specific scenario where it was previously recommended.\r\n\r\n---\r\n\r\nI had suspected in #1685 (see \"The `pythonw` use case\") that calling `Popen` with `shell=True` might no longer be needed, but I did not realize that a change to GitPython, rather than Python or Windows, was responsible, and I was not sure. I now feel sure, due to a combination of the following factors:\r\n\r\n- Official Microsoft documentation of the effect of the `CREATE_NO_WINDOW` [process creation flag](https://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags).\r\n- Addition of a symbolic constant in Python 3.7 [documented accordingly](https://docs.python.org/3/library/subprocess.html#subprocess.CREATE_NO_WINDOW). Note that the technique worked before this, it was just necessary to define the constant or otherwise pass the correct value manually. These days, GitPython only supports Python 3.7 and higher, so the constant can be (and is) used.\r\n- The explanation in 0d93908 (from [#469](https://github.com/gitpython-developers/GitPython/pull/469)) of the improvement of passing the flag.\r\n- **Manual testing, done today.** I improved on the testing procedure I had used in [#1685](https://github.com/gitpython-developers/GitPython/issues/1685) by testing with `pythonw -m idlelib` on Python 3.7.9 and 3.12.1 virtual environments on Windows 10, both with `git.cmd.PROC_CREATIONFLAGS` unmodified, and separately by binding it to `subprocess.CREATE_NEW_PROCESS_GROUP` (i.e., it value without the `CREATE_NO_WINDOW` flag included). Removing the `CREATE_NO_WINDOW` flag, which I had not tried when working on [#1685](https://github.com/gitpython-developers/GitPython/issues/1685), reliably produced a console window that lasted the duration of a `git` command. I tested with the long-running command `git.Repo.clone_from(\"https://github.com/huggingface/transformers.git\", \"transformers\")`.\r\n- Verification that the specific example in the `USE_SHELL` comment, to the extent to which it may have intended other situations where `USE_SHELL = True` was needed, is out of date. That comment points to `test_untracked_files` as a case that requires `USE_SHELL = True` on Windows. CI reveals that test case passes with no special action and with the default of `False`, including on Windows, on all Python versions GitPython supports: [3.7](https://github.com/gitpython-developers/GitPython/actions/runs/7297204582/job/19886104405#step:12:477), [3.8](https://github.com/gitpython-developers/GitPython/actions/runs/7297204582/job/19886104650#step:12:477), [3.9](https://github.com/gitpython-developers/GitPython/actions/runs/7297204582/job/19886104817#step:12:477), [3.10](https://github.com/gitpython-developers/GitPython/actions/runs/7297204582/job/19886105001#step:12:477), [3.11](https://github.com/gitpython-developers/GitPython/actions/runs/7297204582/job/19886105114#step:12:477), [3.12](https://github.com/gitpython-developers/GitPython/actions/runs/7297204582/job/19886105203#step:12:477).\r\n\r\nIt may make sense to deprecate `Git.USE_SHELL`, or to deprecate setting it to `True`. Even before that is determined, however, I think it is worthwhile to change the comment. The main reason I'm opening this as an issue, rather than detailing it in a PR, is so that if the particular wording or other aspects of my proposed change (#1782) end up needing to be rejected or deferred, the issue itself won't be lost track of.","author":{"url":"https://github.com/EliahKagan","@type":"Person","name":"EliahKagan"},"datePublished":"2023-12-22T23:30:51.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1781/GitPython/issues/1781"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0e4ba200-1fea-cffc-ceea-f9feb236036b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE4A8:2B1D7F:54835C:714D92:696828D7
html-safe-noncec12423d1814b7ff649d1616f84b221450cf68dff962caed0fbf8f79e2f69738f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNEE4OjJCMUQ3Rjo1NDgzNUM6NzE0RDkyOjY5NjgyOEQ3IiwidmlzaXRvcl9pZCI6IjIwMDQyNDUwNjQ1MTc2OTE2MDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac082ae33bbc74e3d514bde07476760847dc494134008d91700bef47ed5ca1e203
hovercard-subject-tagissue:2054575217
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/GitPython/1781/issue_layout
twitter:imagehttps://opengraph.githubassets.com/aece7dd0557b6027bfebee960b2ed82f411dfad9cdd9606fe13ba126e3789390/gitpython-developers/GitPython/issues/1781
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/aece7dd0557b6027bfebee960b2ed82f411dfad9cdd9606fe13ba126e3789390/gitpython-developers/GitPython/issues/1781
og:image:altThe Git.USE_SHELL attribute is currently presented this way: GitPython/git/cmd.py Lines 281 to 285 in d986a59 # If True, a shell will be used when executing git commands. # This should only be desi...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameEliahKagan
hostnamegithub.com
expected-hostnamegithub.com
Nonede3218bcb766893a7928ccb72d717c73dff51090f8b63c99bc15f777f34f564e
turbo-cache-controlno-preview
go-importgithub.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git
octolytics-dimension-user_id503709
octolytics-dimension-user_logingitpython-developers
octolytics-dimension-repository_id1126087
octolytics-dimension-repository_nwogitpython-developers/GitPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1126087
octolytics-dimension-repository_network_root_nwogitpython-developers/GitPython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecc29be02c54ce270d26d0adea7a3aa495fbbde57
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/gitpython-developers/GitPython/issues/1781#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2FGitPython%2Fissues%2F1781
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2FGitPython%2Fissues%2F1781
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=gitpython-developers%2FGitPython
Reloadhttps://github.com/gitpython-developers/GitPython/issues/1781
Reloadhttps://github.com/gitpython-developers/GitPython/issues/1781
Reloadhttps://github.com/gitpython-developers/GitPython/issues/1781
gitpython-developers https://github.com/gitpython-developers
GitPythonhttps://github.com/gitpython-developers/GitPython
Please reload this pagehttps://github.com/gitpython-developers/GitPython/issues/1781
Notifications https://github.com/login?return_to=%2Fgitpython-developers%2FGitPython
Fork 964 https://github.com/login?return_to=%2Fgitpython-developers%2FGitPython
Star 5k https://github.com/login?return_to=%2Fgitpython-developers%2FGitPython
Code https://github.com/gitpython-developers/GitPython
Issues 169 https://github.com/gitpython-developers/GitPython/issues
Pull requests 8 https://github.com/gitpython-developers/GitPython/pulls
Discussions https://github.com/gitpython-developers/GitPython/discussions
Actions https://github.com/gitpython-developers/GitPython/actions
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/gitpython-developers/GitPython/security
Please reload this pagehttps://github.com/gitpython-developers/GitPython/issues/1781
Insights https://github.com/gitpython-developers/GitPython/pulse
Code https://github.com/gitpython-developers/GitPython
Issues https://github.com/gitpython-developers/GitPython/issues
Pull requests https://github.com/gitpython-developers/GitPython/pulls
Discussions https://github.com/gitpython-developers/GitPython/discussions
Actions https://github.com/gitpython-developers/GitPython/actions
Security https://github.com/gitpython-developers/GitPython/security
Insights https://github.com/gitpython-developers/GitPython/pulse
New issuehttps://github.com/login?return_to=https://github.com/gitpython-developers/GitPython/issues/1781
New issuehttps://github.com/login?return_to=https://github.com/gitpython-developers/GitPython/issues/1781
#1782https://github.com/gitpython-developers/GitPython/pull/1782
USE_SHELL = True not needed since 2.0.8 but still suggested for Windowshttps://github.com/gitpython-developers/GitPython/issues/1781#top
#1782https://github.com/gitpython-developers/GitPython/pull/1782
acknowledgedhttps://github.com/gitpython-developers/GitPython/issues?q=state%3Aopen%20label%3A%22acknowledged%22
https://github.com/EliahKagan
https://github.com/EliahKagan
EliahKaganhttps://github.com/EliahKagan
on Dec 22, 2023https://github.com/gitpython-developers/GitPython/issues/1781#issue-2054575217
GitPython/git/cmd.pyhttps://github.com/gitpython-developers/GitPython/blob/d986a59467e586afb815d71845f29b605b756cdf/git/cmd.py#L281-L285
d986a59https://github.com/gitpython-developers/GitPython/commit/d986a59467e586afb815d71845f29b605b756cdf
0d93908https://github.com/gitpython-developers/GitPython/commit/0d9390866f9ce42870d3116094cd49e0019a970a
#469https://github.com/gitpython-developers/GitPython/pull/469
process creation flaghttps://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags
GitPython/git/cmd.pyhttps://github.com/gitpython-developers/GitPython/blob/d986a59467e586afb815d71845f29b605b756cdf/git/cmd.py#L231-L236
d986a59https://github.com/gitpython-developers/GitPython/commit/d986a59467e586afb815d71845f29b605b756cdf
#469https://github.com/gitpython-developers/GitPython/pull/469
1c2dd54https://github.com/gitpython-developers/GitPython/commit/1c2dd54358dd526d1d08a8e4a977f041aff74174
3f277bahttps://github.com/gitpython-developers/GitPython/commit/3f277ba01f9a93fb040a365eef80f46ce6a9de85
#126https://github.com/gitpython-developers/GitPython/pull/126
2.0.8https://github.com/gitpython-developers/GitPython/blob/main/doc/source/changes.rst#208---features-and-bugfixes
#469https://github.com/gitpython-developers/GitPython/pull/469
#126https://github.com/gitpython-developers/GitPython/pull/126
#469https://github.com/gitpython-developers/GitPython/pull/469
#1685https://github.com/gitpython-developers/GitPython/issues/1685
process creation flaghttps://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags
documented accordinglyhttps://docs.python.org/3/library/subprocess.html#subprocess.CREATE_NO_WINDOW
0d93908https://github.com/gitpython-developers/GitPython/commit/0d9390866f9ce42870d3116094cd49e0019a970a
#469https://github.com/gitpython-developers/GitPython/pull/469
#1685https://github.com/gitpython-developers/GitPython/issues/1685
#1685https://github.com/gitpython-developers/GitPython/issues/1685
3.7https://github.com/gitpython-developers/GitPython/actions/runs/7297204582/job/19886104405#step:12:477
3.8https://github.com/gitpython-developers/GitPython/actions/runs/7297204582/job/19886104650#step:12:477
3.9https://github.com/gitpython-developers/GitPython/actions/runs/7297204582/job/19886104817#step:12:477
3.10https://github.com/gitpython-developers/GitPython/actions/runs/7297204582/job/19886105001#step:12:477
3.11https://github.com/gitpython-developers/GitPython/actions/runs/7297204582/job/19886105114#step:12:477
3.12https://github.com/gitpython-developers/GitPython/actions/runs/7297204582/job/19886105203#step:12:477
#1782https://github.com/gitpython-developers/GitPython/pull/1782
acknowledgedhttps://github.com/gitpython-developers/GitPython/issues?q=state%3Aopen%20label%3A%22acknowledged%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.