GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — git.cmd.Git.execute(..): fix `with_stdout=False` by ngie-eign · Pull Request #2126 · gitpython-developers/GitPython

Conversation

@ngie-eign

@ngie-eign ngie-eign commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

In the event the end-user called one of the APIs with with_stdout=False, i.e., they didn't want to capture stdout, the code would crash with an AttributeError or ValueError when trying to dereference the stdout/stderr streams attached to Popen(..) objects.

Be more defensive by checking the streams first to make sure they're not None before trying to access their corresponding attributes.

Add myself to AUTHORS and add corresponding regression tests for the change.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ngie-eign
git.cmd.Git.execute(..): fix with_stdout=False
d966a0d
In the event the end-user called one of the APIs with
`with_stdout=False`, i.e., they didn't want to capture stdout, the code
would crash with an AttributeError or ValueError when trying to
dereference the stdout/stderr streams attached to `Popen(..)` objects.

Be more defensive by checking the streams first to make sure they're not
`None` before trying to access their corresponding attributes.

Add myself to AUTHORS and add corresponding regression tests for the
change.

Signed-off-by: Enji Cooper <[email protected]>
@ngie-eign
ngie-eign force-pushed the fix-execute-with_stdout-no-issues branch 3 times, most recently from d3d587c to a64bde9 Compare April 17, 2026 17:04
@Byron
Byron requested a review from Copilot April 18, 2026 02:53
Copilot started reviewing on behalf of Byron April 18, 2026 02:53
View session
Byron
Byron approved these changes Apr 18, 2026
View reviewed changes

@Byron Byron left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot. This looks good to me.

If the machine doesn't find anything horrendous, we can merge this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot AI reviewed Apr 18, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Git.execute(..., with_stdout=False) crashing when stdout/stderr streams are None, and adds regression coverage to prevent future regressions.

Changes:

  • Make Git.execute() defensive against None stdout/stderr streams when stripping newlines, copying output, and closing handles.
  • Add regression tests for with_stdout=False scenarios (with and without output_stream).
  • Add contributor entry to AUTHORS and improve test cleanup robustness in rmtree tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
git/cmd.py Adds None checks around stdout/stderr usage to avoid crashes when stdout isn’t piped.
test/test_git.py Adds regression tests covering with_stdout=False behavior.
test/test_util.py Adds a pytest finalizer to ensure temp directories are cleaned up on platforms with stricter permissions.
AUTHORS Adds a new contributor entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/test_util.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/cmd.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/cmd.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Byron
Byron requested changes Apr 18, 2026
View reviewed changes

@Byron Byron left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs auto-review comments to be addressed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ngie-eign reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@ngie-eign
ngie-eign force-pushed the fix-execute-with_stdout-no-issues branch 2 times, most recently from 0ae13c9 to 335989f Compare April 18, 2026 16:44
@ngie-eign

ngie-eign commented Apr 18, 2026

Copy link
Copy Markdown
Contributor Author

@Byron : I tried dealing with the type hinting issues, but it turned into a lot of onion peeling... I would prefer to delay this for another PR (my WIP branch can be found here: https://github.com/ngie-eign/GitPython/tree/type-checking-rabbit-hole ).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ngie-eign
test_avoids_changing...: don't leave test artifacts behind
6fc4742
Prior to this the test would fail [silently] on my macOS host during the
test and then pytest would complain loudly about it being an issue
post-session (regardless of whether or not the test was being run).

Squash the unwritable directory to mute noise complaints from pytest.

Signed-off-by: Enji Cooper <[email protected]>
@ngie-eign
ngie-eign force-pushed the fix-execute-with_stdout-no-issues branch from 335989f to 6fc4742 Compare April 18, 2026 16:49
@ngie-eign ngie-eign mentioned this pull request Apr 18, 2026
Use subprocess timeout #2127
Closed
@ngie-eign
ngie-eign requested a review from Byron April 18, 2026 18:07
Byron
Byron approved these changes Apr 19, 2026
View reviewed changes

@Byron Byron left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, let's do this!

Getting python to be sane at runtime is a bit like fighting windmills. And since CI isn't failing, I suppose we are fine enough until someone raises an issue.

In any case, an overhaul shouldn't be too bad if it leads to actual improvements, but there is also a danger as GitPython is 'stable' with all its faults, which makes it something to rely on. Or in other words: The tests probably don't cover all uses out there and an overhaul can be dangerous.

Maybe before spending too much time on this, you also have a good use case that shows why this is better and why this library really should. Change.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ngie-eign reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@Byron
Byron merged commit 75e6c6b into gitpython-developers:main Apr 19, 2026
30 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@ngie-eign
ngie-eign deleted the fix-execute-with_stdout-no-issues branch April 20, 2026 20:53
736-c41-2c1-e464fc974 pushed a commit to Swiss-Armed-Forces/Loom that referenced this pull request Apr 27, 2026
open-source Pipeline Loom MR Pipeline Trigger @736-c41-2c1-e464fc974
chore(deps): update dependency gitpython to v3.1.47
20381c1
This MR contains the following updates:

| Package | Type | Update | Change | OpenSSF |
|---|---|---|---|---|
| [gitpython](https://github.com/gitpython-developers/GitPython) | dev | patch | `3.1.46` → `3.1.47` | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/gitpython-developers/GitPython/badge)](https://securityscorecards.dev/viewer/?uri=github.com/gitpython-developers/GitPython) |

---

### Release Notes

<details>
<summary>gitpython-developers/GitPython (gitpython)</summary>

### [`v3.1.47`](https://github.com/gitpython-developers/GitPython/releases/tag/3.1.47): - with security fixes

[Compare Source](gitpython-developers/GitPython@3.1.46...3.1.47)

#### Advisories

- <GHSA-rpm5-65cw-6hj4>
- <GHSA-x2qx-6953-8485>

#### What's Changed

- Prepare next release by [@&#8203;Byron](https://github.com/Byron) in [#&#8203;2095](gitpython-developers/GitPython#2095)
- Bump git/ext/gitdb from `335c0f6` to `4c63ee6` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2096](gitpython-developers/GitPython#2096)
- DOC: README Add urls and updated a relative url by [@&#8203;Timour-Ilyas](https://github.com/Timour-Ilyas) in [#&#8203;2098](gitpython-developers/GitPython#2098)
- Fix GitConfigParser ignoring multiple \[include] path entries by [@&#8203;daniel7an](https://github.com/daniel7an) in [#&#8203;2100](gitpython-developers/GitPython#2100)
- Switch back from Alpine to Debian for WSL by [@&#8203;EliahKagan](https://github.com/EliahKagan) in [#&#8203;2108](gitpython-developers/GitPython#2108)
- Bump git/ext/gitdb from `4c63ee6` to `5c1b303` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2106](gitpython-developers/GitPython#2106)
- Run `gc.collect()` twice in `test_rename` on Python 3.12 by [@&#8203;EliahKagan](https://github.com/EliahKagan) in [#&#8203;2109](gitpython-developers/GitPython#2109)
- fix: guard AutoInterrupt terminate during interpreter shutdown by [@&#8203;lweyrich1](https://github.com/lweyrich1) in [#&#8203;2105](gitpython-developers/GitPython#2105)
- Improve CI infrastructure for pre-commit by [@&#8203;EliahKagan](https://github.com/EliahKagan) in [#&#8203;2110](gitpython-developers/GitPython#2110)
- Bump the pre-commit group with 5 updates by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2111](gitpython-developers/GitPython#2111)
- Upgrade Sphinx for 3.14 support; drop doc build support on 3.8; test 3.14 by [@&#8203;EliahKagan](https://github.com/EliahKagan) in [#&#8203;2112](gitpython-developers/GitPython#2112)
- Fix `Repo.active_branch` resolution for reftable-backed repositories by [@&#8203;Copilot](https://github.com/Copilot) in [#&#8203;2114](gitpython-developers/GitPython#2114)
- docs: warn about GitDB performance with large commits by [@&#8203;mvanhorn](https://github.com/mvanhorn) in [#&#8203;2115](gitpython-developers/GitPython#2115)
- cmd: fix kwarg formatting in docstring example by [@&#8203;UweSchwaeke](https://github.com/UweSchwaeke) in [#&#8203;2117](gitpython-developers/GitPython#2117)
- Bump <https://github.com/astral-sh/ruff-pre-commit> from v0.15.5 to 0.15.8 in the pre-commit group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2122](gitpython-developers/GitPython#2122)
- Add trailer support for commit creation by [@&#8203;Krishnachaitanyakc](https://github.com/Krishnachaitanyakc) in [#&#8203;2116](gitpython-developers/GitPython#2116)
- Harden commit trailer subprocess handling and align trailer I/O paths by [@&#8203;Copilot](https://github.com/Copilot) in [#&#8203;2125](gitpython-developers/GitPython#2125)
- git.cmd.Git.execute(..): fix `with_stdout=False` by [@&#8203;ngie-eign](https://github.com/ngie-eign) in [#&#8203;2126](gitpython-developers/GitPython#2126)
- Make sure that multi-options are checked after splitting them with `shlex` by [@&#8203;Byron](https://github.com/Byron) in [#&#8203;2130](gitpython-developers/GitPython#2130)
- Block unsafe underscored git kwargs / Fix for GHSA-rpm5-65cw-6hj4 by [@&#8203;WesR](https://github.com/WesR) in [#&#8203;2131](gitpython-developers/GitPython#2131)

#### New Contributors

- [@&#8203;Timour-Ilyas](https://github.com/Timour-Ilyas) made their first contribution in [#&#8203;2098](gitpython-developers/GitPython#2098)
- [@&#8203;daniel7an](https://github.com/daniel7an) made their first contribution in [#&#8203;2100](gitpython-developers/GitPython#2100)
- [@&#8203;lweyrich1](https://github.com/lweyrich1) made their first contribution in [#&#8203;2105](gitpython-developers/GitPython#2105)
- [@&#8203;Copilot](https://github.com/Copilot) made their first contribution in [#&#8203;2114](gitpython-developers/GitPython#2114)
- [@&#8203;mvanhorn](https://github.com/mvanhorn) made their first contribution in [#&#8203;2115](gitpython-developers/GitPython#2115)
- [@&#8203;UweSchwaeke](https://github.com/UweSchwaeke) made their first contribution in [#&#8203;2117](gitpython-developers/GitPython#2117)
- [@&#8203;Krishnachaitanyakc](https://github.com/Krishnachaitanyakc) made their first contribution in [#&#8203;2116](gitpython-developers/GitPython#2116)
- [@&#8203;ngie-eign](https://github.com/ngie-eign) made their first contribution in [#&#8203;2126](gitpython-developers/GitPython#2126)
- [@&#8203;WesR](https://github.com/WesR) made their first contribution in [#&#8203;2131](gitpython-developers/GitPython#2131)

**Full Changelog**: <gitpython-developers/GitPython@3.1.46...3.1.47>

</details>

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNDEuNSIsInVwZGF0ZWRJblZlciI6IjQzLjE0MS41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJyZW5vdmF0ZSJdfQ==-->

See merge request swiss-armed-forces/cyber-command/cea/loom!486

Co-authored-by: Loom MR Pipeline Trigger <group_103951964_bot_9504bb8dead6d4e406ad817a607f24be@noreply.gitlab.com>
ngie-eign added a commit to bsdimp/ghpr that referenced this pull request Nov 9, 2026
@ngie-eign
fix: GitHelper.run: support capture passthrough
90ddc7f
Prior to this change, GitPython was broken on earlier versions and
didn't work with `extended_output=True`, as noted in [gitpython#2126].

Several recent changes adjusted the floor version of gitpython required
by the project so dependent versions include the fix to the aforementioned bug.

Make the `capture` passthrough toggleable by the caller, instead of always being wired "on".

This should reduce some memory usage a small bit, and might simplify
some `subprocess` use on the backend by throwing the output from `git`
into a /dev/null "sink".

This change adjusts some of the consuming code to request `capture=True`
explicitly, in order to support this change, e.g., the
`GitConfig.get(..)`.

Signed-off-by: Enji Cooper <[email protected]>

[gitpython#2126]: gitpython-developers/GitPython#2126
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@Byron Byron Byron approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@ngie-eign @Byron
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.