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 — Add context manager protocol for .NET IDisposable types by den-run-ai · Pull Request #2568 · pythonnet/pythonnet

Conversation

@den-run-ai

@den-run-ai den-run-ai commented Mar 23, 2025

Copy link
Copy Markdown
Contributor

What does this implement/fix? Explain your changes.

Implemented IDisposable based on this discussion:
#79

@microsoft-github-policy-service agree

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Ensure you have signed the .NET Foundation CLA
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

Sorry, something went wrong.

Uh oh!

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

michaelblyons and michaelosthege reacted with rocket emoji
All reactions
  • 🚀 2 reactions
@den-run-ai den-run-ai mentioned this pull request Mar 23, 2025
IDisposable should implement the context manager protocol #79
Open
@lostmsu

lostmsu commented Mar 24, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

FYI: tests are not passing

All reactions

Sorry, something went wrong.

Uh oh!

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

@den-run-ai

den-run-ai commented Mar 24, 2025

Copy link
Copy Markdown
Contributor Author

This seems not related to this PR @lostmsu

i tested on mac with .net 8

All reactions

Sorry, something went wrong.

Uh oh!

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

@lostmsu

lostmsu commented Apr 11, 2025

Copy link
Copy Markdown
Member

@den-run-ai This is definitely related to PR, master does not seem to be failing these tests.

All reactions

Sorry, something went wrong.

Uh oh!

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

@michaelblyons

michaelblyons commented May 1, 2025

Copy link
Copy Markdown

For anyone else who is annoyed that the test failures do not provoke backtraces on GitHub's UI,1 here is the output:

_______________________ test_import_all_on_second_time ________________________

    def test_import_all_on_second_time():
        """Test import all attributes after a normal import without '*'.
        Due to import * only allowed at module level, the test body splitted
        to a module file."""
>       from . import importtest

tests\test_import.py:20: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    import sys
    try:
        del sys.modules["System.IO"]
    except KeyError:
        pass
    
    assert "FileStream" not in globals()
    import System.IO
    from System.IO import *
    
>   assert "FileStream" in globals()
E   AssertionError

tests\importtest.py:13: AssertionError

My (uninitiated) interpretation is that some cruft is left hanging around despite the Dispose() call.

Footnotes

  1. And also lest the test artefacts age away. ↩

All reactions

Sorry, something went wrong.

Uh oh!

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

@filmor
filmor force-pushed the feature/context-manager-disposable branch from 91c9670 to 4edf14c Compare May 5, 2026 16:23
@filmor

filmor commented May 7, 2026

Copy link
Copy Markdown
Member

The test-error is unrelated, it shows up because the test-suite imports FileStream which is used in the import test. I will follow up on this in #2717.

michaelblyons reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

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

den-run-ai and others added 4 commits May 7, 2026 19:55
den-run-ai @filmor
Add context manager protocol for .NET IDisposable types
15de5fa
den-run-ai @filmor
update docs
d6fda69
den-run-ai @filmor
author fix
2256ff1
@filmor
Use pytest for the disposable tests
7ed43bd
@filmor
filmor force-pushed the feature/context-manager-disposable branch from 959f544 to 7ed43bd Compare May 7, 2026 17:55
filmor
filmor approved these changes May 7, 2026
View reviewed changes
@filmor
filmor merged commit 25e0ccf into pythonnet:master May 11, 2026
80 of 83 checks passed

Uh oh!

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

This was referenced May 24, 2026
Bump pythonnet from 3.0.5 to 3.1.0 zcsizmadia/PyDotNet#12
Merged
chore: Bump pythonnet from 3.0.5 to 3.1.0 apache/arrow-dotnet#364
Merged
CurtHagenlocher pushed a commit to apache/arrow-dotnet that referenced this pull request May 25, 2026
@dependabot
chore: Bump pythonnet from 3.0.5 to 3.1.0 (#364)
5c6a0c9
Updated [pythonnet](https://github.com/pythonnet/pythonnet) from 3.0.5
to 3.1.0.

<details>
<summary>Release notes</summary>

_Sourced from [pythonnet's
releases](https://github.com/pythonnet/pythonnet/releases)._

## 3.1.0

## What's Changed
* ci: properly exclude job by @​RobPasMue in
pythonnet/pythonnet#2542
* `__delitem__` for `IList<T>` and `IDictionary<K,V>` by @​lostmsu in
pythonnet/pythonnet#2533
* Fix docs workflow by @​filmor in
pythonnet/pythonnet#2584
* Drop EOLd Python versions by @​filmor in
pythonnet/pythonnet#2632
* Bump setuptools and adjust license information by @​filmor in
pythonnet/pythonnet#2633
* Minimal .NET 8 usage changes by @​filmor in
pythonnet/pythonnet#2634
* Drop performance tests by @​filmor in
pythonnet/pythonnet#2636
* Properly detect availability of BinaryFormatter by @​filmor in
pythonnet/pythonnet#2639
* Use last compiler toolset version that support .NET 8 by @​filmor in
pythonnet/pythonnet#2640
* Add dependabot file by @​filmor in
pythonnet/pythonnet#2642
* Use official ARM runners by @​filmor in
pythonnet/pythonnet#2641
* Bump actions/upload-pages-artifact from 3 to 4 by @​dependabot[bot] in
pythonnet/pythonnet#2644
* Bump actions/setup-python from 2 to 6 by @​dependabot[bot] in
pythonnet/pythonnet#2646
* Bump actions/checkout from 2 to 5 by @​dependabot[bot] in
pythonnet/pythonnet#2648
* Bump actions/setup-dotnet from 1 to 5 by @​dependabot[bot] in
pythonnet/pythonnet#2645
* Use uv and derive as much as possible from the environment, if
available by @​filmor in
pythonnet/pythonnet#2652
* Fixes for the uv CI by @​filmor in
pythonnet/pythonnet#2654
* Bump astral-sh/setup-uv from 6 to 7 by @​dependabot[bot] in
pythonnet/pythonnet#2656
* Bump actions/checkout from 5 to 6 by @​dependabot[bot] in
pythonnet/pythonnet#2663
* Ensure that the tests work even if BinaryFormatter is not available by
@​filmor in pythonnet/pythonnet#2638
* Bump NUnit3TestAdapter from 5.2.0 to 6.0.0 by @​dependabot[bot] in
pythonnet/pythonnet#2667
* Fix line endings by @​filmor in
pythonnet/pythonnet#2668
* Switch to .NET SDK 10 by @​lostmsu in
pythonnet/pythonnet#2684
* Python 3.14 by @​filmor in
pythonnet/pythonnet#2611
* CI Improvements by @​filmor in
pythonnet/pythonnet#2669
* Bump System.Reflection.Emit from 4.3.0 to 4.7.0 by @​dependabot[bot]
in pythonnet/pythonnet#2694
* Bump pytest from 9.0.2 to 9.0.3 in the uv group across 1 directory by
@​dependabot[bot] in pythonnet/pythonnet#2705
* CI Improvements by @​filmor in
pythonnet/pythonnet#2707
* Fix method memleak test by @​filmor in
pythonnet/pythonnet#2708
* Bump actions/upload-pages-artifact from 4 to 5 by @​dependabot[bot] in
pythonnet/pythonnet#2709
* Update furo requirement from >=2022.9.15 to >=2025.12.19 by
@​dependabot[bot] in pythonnet/pythonnet#2711
* Move documentation deps to pyproject.toml by @​filmor in
pythonnet/pythonnet#2714
* Support .NET Framework 4.6.1 by @​Metadorius in
pythonnet/pythonnet#2701
* Fix wheel tags by @​filmor in
pythonnet/pythonnet#2716
* Name missing from __all__ on re-import by @​filmor in
pythonnet/pythonnet#2717
* Add context manager protocol for .NET IDisposable types by
@​den-run-ai in pythonnet/pythonnet#2568
* Fix MethodBinding/OverloadMapper memory leak (#​691) by
@​greateggsgreg in pythonnet/pythonnet#2719
* Bump urllib3 from 2.6.3 to 2.7.0 in the uv group across 1 directory by
@​dependabot[bot] in pythonnet/pythonnet#2723
* Update NUnit by @​filmor in
pythonnet/pythonnet#2724
* Silence compile-time warnings by @​filmor in
pythonnet/pythonnet#2725
* Implement support for DLR get/set by @​filmor in
pythonnet/pythonnet#2706
* Bump idna from 3.13 to 3.15 in the uv group across 1 directory by
@​dependabot[bot] in pythonnet/pythonnet#2726

## New Contributors
* @​RobPasMue made their first contribution in
pythonnet/pythonnet#2542
* @​dependabot[bot] made their first contribution in
pythonnet/pythonnet#2644
* @​Metadorius made their first contribution in
pythonnet/pythonnet#2701

**Full Changelog**:
pythonnet/pythonnet@v3.0.5...v3.1.0

## 3.1.0-rc1

## What's Changed
* CI Improvements by @​filmor in
pythonnet/pythonnet#2669
* Bump System.Reflection.Emit from 4.3.0 to 4.7.0 by @​dependabot[bot]
in pythonnet/pythonnet#2694
* Bump pytest from 9.0.2 to 9.0.3 in the uv group across 1 directory by
@​dependabot[bot] in pythonnet/pythonnet#2705
* CI Improvements by @​filmor in
pythonnet/pythonnet#2707
* Fix method memleak test by @​filmor in
pythonnet/pythonnet#2708
* Bump actions/upload-pages-artifact from 4 to 5 by @​dependabot[bot] in
pythonnet/pythonnet#2709
* Update furo requirement from >=2022.9.15 to >=2025.12.19 by
@​dependabot[bot] in pythonnet/pythonnet#2711
* Move documentation deps to pyproject.toml by @​filmor in
pythonnet/pythonnet#2714
* Support .NET Framework 4.6.1 by @​Metadorius in
pythonnet/pythonnet#2701
* Fix wheel tags by @​filmor in
pythonnet/pythonnet#2716
* Name missing from __all__ on re-import by @​filmor in
pythonnet/pythonnet#2717
* Add context manager protocol for .NET IDisposable types by
@​den-run-ai in pythonnet/pythonnet#2568
* Fix MethodBinding/OverloadMapper memory leak (#​691) by
@​greateggsgreg in pythonnet/pythonnet#2719
* Bump urllib3 from 2.6.3 to 2.7.0 in the uv group across 1 directory by
@​dependabot[bot] in pythonnet/pythonnet#2723
* Update NUnit by @​filmor in
pythonnet/pythonnet#2724
* Silence compile-time warnings by @​filmor in
pythonnet/pythonnet#2725
* Implement support for DLR get/set by @​filmor in
pythonnet/pythonnet#2706

## New Contributors
* @​Metadorius made their first contribution in
pythonnet/pythonnet#2701

**Full Changelog**:
pythonnet/pythonnet@v3.1.0-rc0...v3.1.0-rc1

## 3.1.0-rc0

## What's Changed
* ci: properly exclude job by @​RobPasMue in
pythonnet/pythonnet#2542
* `__delitem__` for `IList<T>` and `IDictionary<K,V>` by @​lostmsu in
pythonnet/pythonnet#2533
* Fix docs workflow by @​filmor in
pythonnet/pythonnet#2584
* Drop EOLd Python versions by @​filmor in
pythonnet/pythonnet#2632
* Bump setuptools and adjust license information by @​filmor in
pythonnet/pythonnet#2633
* Minimal .NET 8 usage changes by @​filmor in
pythonnet/pythonnet#2634
* Drop performance tests by @​filmor in
pythonnet/pythonnet#2636
* Properly detect availability of BinaryFormatter by @​filmor in
pythonnet/pythonnet#2639
* Use last compiler toolset version that support .NET 8 by @​filmor in
pythonnet/pythonnet#2640
* Add dependabot file by @​filmor in
pythonnet/pythonnet#2642
* Use official ARM runners by @​filmor in
pythonnet/pythonnet#2641
* Use uv and derive as much as possible from the environment, if
available by @​filmor in
pythonnet/pythonnet#2652
* Fixes for the uv CI by @​filmor in
pythonnet/pythonnet#2654
* Ensure that the tests work even if BinaryFormatter is not available by
@​filmor in pythonnet/pythonnet#2638
* Fix line endings by @​filmor in
pythonnet/pythonnet#2668
* Switch to .NET SDK 10 by @​lostmsu in
pythonnet/pythonnet#2684
* Python 3.14 by @​filmor in
pythonnet/pythonnet#2611

## New Contributors
* @​RobPasMue made their first contribution in
pythonnet/pythonnet#2542
* @​dependabot[bot] made their first contribution in
pythonnet/pythonnet#2644

**Full Changelog**:
pythonnet/pythonnet@v3.0.5...v3.1.0-rc0

Commits viewable in [compare
view](pythonnet/pythonnet@v3.0.5...v3.1.0).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pythonnet&package-manager=nuget&previous-version=3.0.5&new-version=3.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

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-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

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 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)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@dependabot dependabot Bot mentioned this pull request May 25, 2026
🔼 NuGet: Bump pythonnet from 3.0.5 to 3.1.0 Kestrun/Kestrun#411
Open
@Martin-Molinero Martin-Molinero mentioned this pull request Jun 18, 2026
Add context manager protocol for .NET IDisposable types QuantConnect/pythonnet#119
Closed
@dependabot dependabot Bot mentioned this pull request Oct 10, 2026
Bump pythonnet from 3.0.5 to 3.2.1 baleti/revit-ballet#3
Open
@dependabot dependabot Bot mentioned this pull request Oct 28, 2026
build: Bump pythonnet from 3.0.5 to 3.2.1 akuro17/StockAnalyzer-OSS#89
Open
@dependabot dependabot Bot mentioned this pull request Nov 10, 2026
MINOR: [C#] Bump pythonnet from 3.0.4 to 3.2.1 sg-scale/arrow--apache-arrow-18.1.0#10
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@filmor filmor filmor approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

None yet

Projects

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.

4 participants

@den-run-ai @lostmsu @michaelblyons @filmor
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.