Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util: close lockfile after opening successfully #1639

Merged
merged 1 commit into from
Sep 2, 2023

Conversation

skshetry
Copy link
Contributor

@skshetry skshetry commented Sep 2, 2023

Otherwise, this will leak file handles and can be a problem in Windows. Also, closefd=true is the default here, so no need to pass it explicitly.

Regression from #1619.

I noticed after our tests started raising ResourceWarning after 3.1.33 release.

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.17/x64/lib/python3.8/site-packages/git/util.py", line 938, in _obtain_lock_or_raise
    open(lock_file, mode='w', closefd=True)
ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/pytest-of-runner/pytest-0/popen-gw0/external0/project.git/.git/config.lock' mode='w' encoding='UTF-8'>

Otherwise, this will leak file handles and can be a problem in Windows.
Also, `closefd=true` is the default here, so need to pass it explicitly.

Regression from gitpython-developers#1619.

I noticed after [our tests started raising `ResourceWarning`][1].

```python
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.17/x64/lib/python3.8/site-packages/git/util.py", line 938, in _obtain_lock_or_raise
    open(lock_file, mode='w', closefd=True)
ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/pytest-of-runner/pytest-0/popen-gw0/external0/project.git/.git/config.lock' mode='w' encoding='UTF-8'>
```

[1]: https://github.com/iterative/dvc/actions/runs/6055520480/job/16434544764#step:6:869
@Byron Byron added this to the v3.1.34 - Bugfixes milestone Sep 2, 2023
@Byron Byron merged commit 4714740 into gitpython-developers:main Sep 2, 2023
7 checks passed
@Byron
Copy link
Member

Byron commented Sep 2, 2023

Thanks for the fix and sorry for this! I reviewed the change and when reading closefd I thought it closes the returned resource right away. After reading the actual docs I realize that was just a trap.

I will create a new release shortly.

@Byron
Copy link
Member

Byron commented Sep 2, 2023

https://pypi.org/project/GitPython/3.1.34/

@skshetry skshetry deleted the close-lockfile branch September 2, 2023 11:14
renovate bot referenced this pull request in allenporter/flux-local Sep 4, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [GitPython](https://github.com/gitpython-developers/GitPython) |
`==3.1.32` -> `==3.1.34` |
[![age](https://developer.mend.io/api/mc/badges/age/pypi/GitPython/3.1.34?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/GitPython/3.1.34?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/GitPython/3.1.32/3.1.34?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/GitPython/3.1.32/3.1.34?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

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

###
[`v3.1.34`](https://github.com/gitpython-developers/GitPython/releases/tag/3.1.34):
- fix resource leaking

[Compare
Source](https://github.com/gitpython-developers/GitPython/compare/3.1.33...3.1.34)

##### What's Changed

- util: close lockfile after opening successfully by
[@&#8203;skshetry](https://github.com/skshetry) in
[https://github.com/gitpython-developers/GitPython/pull/1639](https://github.com/gitpython-developers/GitPython/pull/1639)

##### New Contributors

- [@&#8203;skshetry](https://github.com/skshetry) made their first
contribution in
[https://github.com/gitpython-developers/GitPython/pull/1639](https://github.com/gitpython-developers/GitPython/pull/1639)

**Full Changelog**:
gitpython-developers/GitPython@3.1.33...3.1.34

###
[`v3.1.33`](https://github.com/gitpython-developers/GitPython/releases/tag/3.1.33):
- with security fix

[Compare
Source](https://github.com/gitpython-developers/GitPython/compare/3.1.32...3.1.33)

##### What's Changed

- WIP Quick doc by [@&#8203;LeoDaCoda](https://github.com/LeoDaCoda)
in
[https://github.com/gitpython-developers/GitPython/pull/1608](https://github.com/gitpython-developers/GitPython/pull/1608)
- Partial clean up wrt mypy and black by
[@&#8203;bodograumann](https://github.com/bodograumann) in
[https://github.com/gitpython-developers/GitPython/pull/1617](https://github.com/gitpython-developers/GitPython/pull/1617)
- Disable merge_includes in config writers by
[@&#8203;bodograumann](https://github.com/bodograumann) in
[https://github.com/gitpython-developers/GitPython/pull/1618](https://github.com/gitpython-developers/GitPython/pull/1618)
- feat: full typing for "progress" parameter in Repo class by
[@&#8203;madebylydia](https://github.com/madebylydia) in
[https://github.com/gitpython-developers/GitPython/pull/1634](https://github.com/gitpython-developers/GitPython/pull/1634)
- Fix CVE-2023-40590 by
[@&#8203;EliahKagan](https://github.com/EliahKagan) in
[https://github.com/gitpython-developers/GitPython/pull/1636](https://github.com/gitpython-developers/GitPython/pull/1636)
-
[#&#8203;1566](https://github.com/gitpython-developers/GitPython/issues/1566)
Creating a lock now uses python built-in "open()" method to work arou…
by [@&#8203;HageMaster3108](https://github.com/HageMaster3108) in
[https://github.com/gitpython-developers/GitPython/pull/1619](https://github.com/gitpython-developers/GitPython/pull/1619)

##### New Contributors

- [@&#8203;LeoDaCoda](https://github.com/LeoDaCoda) made their first
contribution in
[https://github.com/gitpython-developers/GitPython/pull/1608](https://github.com/gitpython-developers/GitPython/pull/1608)
- [@&#8203;bodograumann](https://github.com/bodograumann) made their
first contribution in
[https://github.com/gitpython-developers/GitPython/pull/1617](https://github.com/gitpython-developers/GitPython/pull/1617)
- [@&#8203;EliahKagan](https://github.com/EliahKagan) made their first
contribution in
[https://github.com/gitpython-developers/GitPython/pull/1636](https://github.com/gitpython-developers/GitPython/pull/1636)
- [@&#8203;HageMaster3108](https://github.com/HageMaster3108) made
their first contribution in
[https://github.com/gitpython-developers/GitPython/pull/1619](https://github.com/gitpython-developers/GitPython/pull/1619)

**Full Changelog**:
gitpython-developers/GitPython@3.1.32...3.1.33

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

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

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/allenporter/flux-local).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi43OC44IiwidXBkYXRlZEluVmVyIjoiMzYuNzguOCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
otc-zuul bot pushed a commit to opentelekomcloud-infra/eyes_on_docs that referenced this pull request Sep 11, 2023
Bump gitpython from 3.1.32 to 3.1.35

Bumps gitpython from 3.1.32 to 3.1.35.

Release notes
Sourced from gitpython's releases.

3.1.35 - a fix for CVE-2023-41040
What's Changed

Bump actions/checkout from 3 to 4 by @​dependabot in gitpython-developers/GitPython#1643
Fix 'Tree' object has no attribute '_name' when submodule path is normal path by @​CosmosAtlas in gitpython-developers/GitPython#1645
Fix CVE-2023-41040 by @​facutuesca in gitpython-developers/GitPython#1644
Only make config more permissive in tests that need it by @​EliahKagan in gitpython-developers/GitPython#1648
Added test for PR #1645 submodule path by @​CosmosAtlas in gitpython-developers/GitPython#1647
Fix Windows environment variable upcasing bug by @​EliahKagan in gitpython-developers/GitPython#1650

New Contributors

@​CosmosAtlas made their first contribution in gitpython-developers/GitPython#1645
@​facutuesca made their first contribution in gitpython-developers/GitPython#1644

Full Changelog: gitpython-developers/GitPython@3.1.34...3.1.35
3.1.34 - fix resource leaking
What's Changed

util: close lockfile after opening successfully by @​skshetry in gitpython-developers/GitPython#1639

New Contributors

@​skshetry made their first contribution in gitpython-developers/GitPython#1639

Full Changelog: gitpython-developers/GitPython@3.1.33...3.1.34
v3.1.33 - with security fix
What's Changed

WIP Quick doc by @​LeoDaCoda in gitpython-developers/GitPython#1608
Partial clean up wrt mypy and black by @​bodograumann in gitpython-developers/GitPython#1617
Disable merge_includes in config writers by @​bodograumann in gitpython-developers/GitPython#1618
feat: full typing for "progress" parameter in Repo class by @​madebylydia in gitpython-developers/GitPython#1634
Fix CVE-2023-40590 by @​EliahKagan in gitpython-developers/GitPython#1636
#1566 Creating a lock now uses python built-in "open()" method to work arou… by @​HageMaster3108 in gitpython-developers/GitPython#1619

New Contributors

@​LeoDaCoda made their first contribution in gitpython-developers/GitPython#1608
@​bodograumann made their first contribution in gitpython-developers/GitPython#1617
@​EliahKagan made their first contribution in gitpython-developers/GitPython#1636
@​HageMaster3108 made their first contribution in gitpython-developers/GitPython#1619

Full Changelog: gitpython-developers/GitPython@3.1.32...3.1.33



Commits

c8e303f prepare next release
09e1b3d Merge pull request #1650 from EliahKagan/envcase
8017421 Merge pull request #1647 from CosmosAtlas/master
fafb4f6 updated docs to better describe testing procedure with new repo
9da24d4 add test for submodule path not owned by submodule case
eebdb25 Eliminate duplication of git.util.cwd logic
c7fad20 Fix Windows env var upcasing regression
7296e5c Make test helper script a file, for readability
d88372a Add test for Windows env var upcasing regression
11839ab Merge pull request #1648 from EliahKagan/file-protocol
Additional commits viewable in compare view




Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

@dependabot rebase will rebase this PR
@dependabot recreate will recreate this PR, overwriting any edits that have been made to it
@dependabot merge will merge this PR after your CI passes on it
@dependabot squash and merge will squash and merge this PR after your CI passes on it
@dependabot cancel merge will cancel a previously requested merge and block automerging
@dependabot reopen will reopen this PR if it is closed
@dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
@dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
@dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
@dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
@dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the Security Alerts page.

Reviewed-by: Vladimir Vshivkov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants