Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6a8a97d
Fix CI by using macos-13 explicitly, adjust OS config (#2373)
filmor May 5, 2024
195cde6
Use non-BOM encodings (#2370)
filmor May 10, 2024
32051cb
Expose serialization api (#2336)
BadSingleton May 10, 2024
b112885
handle bad paths in sys.path (#2383)
lostmsu May 11, 2024
4e5afdf
Fix access violation exception on shutdown (#1977)
Frawak May 13, 2024
6f0f671
Restrict first garbage collection
Frawak May 13, 2024
f82aeea
Simplify UTF8 StrPtr usage (#2374)
filmor Jun 8, 2024
9ebfbde
Fix crash when event does not have `Add` method and improve message f…
lostmsu Jul 2, 2024
c99cdf3
Throw exception trying to add a reflected object after the hashset is…
Frawak Jul 8, 2024
6cdd6d7
Move reflected object creation block
Frawak Aug 5, 2024
ea059ca
Merge pull request #2386 from Frawak/fix/1977-access-violation-gc
lostmsu Aug 6, 2024
6690310
Bump to 3.0.4
filmor Sep 19, 2024
5c50b20
Back to dev
filmor Sep 19, 2024
de7a1d2
Drop console application (#2456)
filmor Oct 1, 2024
0ea1d29
Drop reference to Py_Main (#2504)
filmor Nov 8, 2024
7a9e3bf
Stick to ubuntu-22.04 for now as that image still contains Mono
filmor Dec 11, 2024
5cf2534
First attempt at Python 3.13
filmor Sep 19, 2024
2f3a0e7
Add Python 3.13 to CI
filmor Oct 25, 2024
5a7b5be
Update project file
filmor Oct 25, 2024
f3face0
Use PyThreadState_GetUnchecked on Python 3.13
filmor Dec 11, 2024
88d98f2
Workaround for geninterop failure to handle non-pointer fields
filmor Dec 12, 2024
4bb673f
Bump clr-loader and dev dependencies
filmor Dec 12, 2024
8283627
Raise maximum supported version
filmor Dec 12, 2024
1920b19
Xfail a test that only fails locally on my machine right now
filmor Dec 12, 2024
60a057f
Skip embed tests on Python 3.13 for now
filmor Dec 13, 2024
8f0ccb7
Add changelog entry
filmor Dec 13, 2024
7c87fec
Workaround for setuptools bug #4759
filmor Dec 13, 2024
0ea8e6f
Remove win-x86-py3.13 entirely for now
filmor Dec 13, 2024
4132a36
Merge pull request #2454 from pythonnet/python3.13
filmor Dec 13, 2024
0826fc0
Release 3.0.5
filmor Dec 13, 2024
f361fa9
Back to dev
filmor Dec 13, 2024
dfd746b
Drop icon
filmor Dec 13, 2024
030a9f9
ci: properly exclude job (#2542)
RobPasMue Feb 20, 2025
a674658
added NixOS FHS shell.nix
lostmsu Dec 18, 2024
ac605fd
index setter was leaking memory
lostmsu Dec 18, 2024
77bdf6d
implemented __delitem__ for IDictionary<K,V> and IList<T>
lostmsu Dec 18, 2024
a21c797
Bump action versions in doc workflow (#2584)
filmor Apr 14, 2025
1bc1b91
Merge remote-tracking branch 'upstream/master' into feature/rebase-up…
ivaylo-matov Sep 2, 2025
d98e811
Delete docs.yml
ivaylo-matov Sep 2, 2025
85d253f
bumped up version
ivaylo-matov Sep 3, 2025
9c645a8
update to NET8.0
ivaylo-matov Sep 23, 2025
e19720f
tests
ivaylo-matov Sep 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ jobs:
platform: x64
instance: macos-13

python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

# This fails in pytest with:
# CSC : error CS4023: /platform:anycpu32bitpreferred can only be used with /t:exe, /t:winexe and /t:appcontainerexe [D:\a\pythonnet\pythonnet\src\runtime\Python.Runtime.csproj]
exclude:
- os:
category: windows
platform: x86
python: "3.13"

steps:
- name: Set Environment on macOS
Expand Down Expand Up @@ -77,6 +85,7 @@ jobs:
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append -InputObject "PYTHONHOME=$(python -c 'import sys; print(sys.prefix)')"

- name: Embedding tests
if: ${{ matrix.python != '3.13' }}
run: dotnet test --runtime any-${{ matrix.os.platform }} --logger "console;verbosity=detailed" src/embed_tests/
env:
MONO_THREADS_SUSPEND: preemptive # https://github.com/mono/mono/issues/21466
Expand All @@ -95,6 +104,7 @@ jobs:
run: pytest --runtime netfx

- name: Python tests run from .NET
if: ${{ matrix.python != '3.13' }}
run: dotnet test --runtime any-${{ matrix.os.platform }} src/python_tests_runner/

# - name: Perf tests
Expand Down
2 changes: 2 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- Dmitriy Se ([@dmitriyse](https://github.com/dmitriyse))
- Félix Bourbonnais ([@BadSingleton](https://github.com/BadSingleton))
- Florian Treurniet ([@ftreurni](https://github.com/ftreurni))
- Frank Witscher ([@Frawak](https://github.com/Frawak))
- He-chien Tsai ([@t3476](https://github.com/t3476))
- Inna Wiesel ([@inna-w](https://github.com/inna-w))
- Ivan Cronyn ([@cronan](https://github.com/cronan))
Expand All @@ -58,6 +59,7 @@
- Peter Kese ([@pkese](https://github.com/pkese))
- Raphael Nestler ([@rnestler](https://github.com/rnestler))
- Rickard Holmberg ([@rickardraysearch](https://github.com/rickardraysearch))
- Roberto Pastor Muela ([@RobPasMue](https://github.com/RobPasMue))
- Sam Winstanley ([@swinstanley](https://github.com/swinstanley))
- Sean Freitag ([@cowboygneox](https://github.com/cowboygneox))
- Serge Weinstock ([@sweinst](https://github.com/sweinst))
Expand Down
37 changes: 36 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ project adheres to [Semantic Versioning][].

This document follows the conventions laid out in [Keep a CHANGELOG][].

## [Unreleased][]
## Unreleased

### Added

Expand All @@ -16,15 +16,49 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
- Added `ToPythonAs<T>()` extension method to allow for explicit conversion using a specific type. ([#2311][i2311])
- Added `IComparable` and `IEquatable` implementations to `PyInt`, `PyFloat`, and `PyString`
to compare with primitive .NET types like `long`.
- Support `del obj[...]` for types derived from `IList<T>` and `IDictionary<K, V>`

### Changed
### Fixed

- Fixed crash when trying to `del clrObj[...]` for non-arrays
- ci: properly exclude job (#2542)

## [3.0.5](https://github.com/pythonnet/pythonnet/releases/tag/v3.0.5) - 2024-12-13

### Added

- Support for Python 3.13 (#2454)


## [3.0.4](https://github.com/pythonnet/pythonnet/releases/tag/v3.0.4) - 2024-09-19

### Added

- Added `ToPythonAs<T>()` extension method to allow for explicit conversion
using a specific type. ([#2311][i2311])
- Added `IComparable` and `IEquatable` implementations to `PyInt`, `PyFloat`,
and `PyString` to compare with primitive .NET types like `long`.

### Changed

- Added a `FormatterFactory` member in RuntimeData to create formatters with
parameters. For compatibility, the `FormatterType` member is still present
and has precedence when defining both `FormatterFactory` and `FormatterType`
- Added a post-serialization and a pre-deserialization step callbacks to
extend (de)serialization process
- Added an API to stash serialized data on Python capsules

- Do not set errors when type conversion fails for valid reasons. See (https://git.autodesk.com/Dynamo/pythonnet/pull/64)
- Improve error handling when dlls import fail. See (https://git.autodesk.com/Dynamo/pythonnet/pull/63)

### Fixed

- Fixed RecursionError for reverse operators on C# operable types from python. See #2240
- Fixed crash when .NET event has no `AddMethod`
- Fixed probing for assemblies in `sys.path` failing when a path in `sys.path`
has invalid characters. See #2376
- Fixed possible access violation exception on shutdown. See ([#1977][i1977])

- Fixed operators overloading conflict with unbounded, extension method identification. See (https://git.autodesk.com/Dynamo/pythonnet/pull/47)

Expand Down Expand Up @@ -974,3 +1008,4 @@ This version improves performance on benchmarks significantly compared to 2.3.
[i1481]: https://github.com/pythonnet/pythonnet/issues/1481
[i1672]: https://github.com/pythonnet/pythonnet/pull/1672
[i2311]: https://github.com/pythonnet/pythonnet/issues/2311
[i1977]: https://github.com/pythonnet/pythonnet/issues/1977
15 changes: 13 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ license = {text = "MIT"}
readme = "README.rst"

dependencies = [
"clr_loader>=0.2.6,<0.3.0"
"clr_loader>=0.2.7,<0.3.0"
]

requires-python = ">=3.7, <3.13"
requires-python = ">=3.7, <3.14"

classifiers = [
"Development Status :: 5 - Production/Stable",
Expand All @@ -27,13 +27,23 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
]

dynamic = ["version"]

[dependency-groups]
dev = [
"pytest >= 6",
"find_libpython >= 0.3.0",
"numpy >=2 ; python_version >= '3.10'",
"numpy <2 ; python_version < '3.10'",
"psutil"
]

[[project.authors]]
name = "The Contributors of the Python.NET Project"
email = "pythonnet@python.org"
Expand All @@ -45,6 +55,7 @@ Sources = "https://github.com/pythonnet/pythonnet"
[tool.setuptools]
zip-safe = false
py-modules = ["clr"]
license-files = []

[tool.setuptools.dynamic.version]
file = "version.txt"
Expand Down
3 changes: 1 addition & 2 deletions pythonnet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ VisualStudioVersion = 17.0.31912.275
MinimumVisualStudioVersion = 15.0.26124.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Runtime", "src\runtime\Python.Runtime.csproj", "{4E8C8FE2-0FB8-4517-B2D9-5FB2D5FC849B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console", "src\console\Console.csproj", "{E6B01706-00BA-4144-9029-186AC42FBE9A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.EmbeddingTest", "src\embed_tests\Python.EmbeddingTest.csproj", "{819E089B-4770-400E-93C6-4F7A35F0EA12}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Test", "src\testing\Python.Test.csproj", "{14EF9518-5BB7-4F83-8686-015BD2CC788E}"
Expand All @@ -22,6 +20,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Repo", "Repo", "{441A0123-F
LICENSE = LICENSE
README.rst = README.rst
version.txt = version.txt
shell.nix = shell.nix
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CI", "CI", "{D301657F-5EAF-4534-B280-B858D651B2E5}"
Expand Down
10 changes: 10 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{ pkgs ? import <nixpkgs> {}}:
let
fhs = pkgs.buildFHSUserEnv {
name = "my-fhs-environment";

targetPkgs = _: [
pkgs.python3
];
};
in fhs.env
27 changes: 0 additions & 27 deletions src/console/Console.csproj

This file was deleted.

Binary file removed src/console/python-clear.ico
Binary file not shown.
Binary file removed src/console/python-clear.png
Binary file not shown.
82 changes: 0 additions & 82 deletions src/console/pythonconsole.cs

This file was deleted.

26 changes: 26 additions & 0 deletions src/embed_tests/BinaryFormatterOptIn.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using NUnit.Framework;

namespace Python.EmbeddingTest
{
//.NET 7/8 disables BinaryFormatter at runtime for security reasons.
//Some of our pythonnet tests (and pythonnet’s shutdown path via RuntimeData.Stash)
//still use BinaryFormatter to round-trip internal state (e.g., MethodBase, runtime
//caches). Without opting in, tests throw NotSupportedException on .NET 7/8.
//We enable BinaryFormatter *for this test process only* by setting the official
//AppContext switch once before any tests run. This is safe for tests and does not
//affect production code. The switch is guarded by NET7_0_OR_GREATER so it’s a no-op
//on older TFMs (e.g., net472).
[SetUpFixture]
public class BinaryFormatterOptIn
{
[OneTimeSetUp]
public void Enable()
{
#if NET7_0_OR_GREATER
System.AppContext.SetSwitch(
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization", true);
#endif
}
}
}
2 changes: 1 addition & 1 deletion src/embed_tests/Python.EmbeddingTest.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<AssemblyOriginatorKeyFile>..\pythonnet.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/embed_tests/TestPyType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public void CanCreateHeapType()
const string name = "nÁmæ";
const string docStr = "dÁcæ";

using var doc = new StrPtr(docStr, Encoding.UTF8);
using var doc = new StrPtr(docStr);

var spec = new TypeSpec(
name: name,
basicSize: Util.ReadInt32(Runtime.Runtime.PyBaseObjectType, TypeOffset.tp_basicsize),
Expand Down
2 changes: 1 addition & 1 deletion src/module_tests/Python.ModuleTest.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<AssemblyOriginatorKeyFile>..\pythonnet.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/python_tests_runner/Python.PythonTestsRunner.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -11,11 +11,11 @@

<ItemGroup>
<PackageReference Include="NUnit" Version="3.*" />
<PackageReference Include="NUnit3TestAdapter" Version="3.*">
<PackageReference Include="NUnit3TestAdapter" Version="4.*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.*" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Condition="$(MSBuildRuntimeType) == 'Core'">
<Version>1.0.0</Version>
<PrivateAssets>all</PrivateAssets>
Expand Down
7 changes: 7 additions & 0 deletions src/runtime/AssemblyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ static IEnumerable<string> FindAssemblyCandidates(string name)
}
else
{
int invalidCharIndex = head.IndexOfAny(Path.GetInvalidPathChars());
if (invalidCharIndex >= 0)
{
using var importWarning = Runtime.PyObject_GetAttrString(Exceptions.exceptions_module, "ImportWarning");
Exceptions.warn($"Path entry '{head}' has invalid char at position {invalidCharIndex}", importWarning.BorrowOrThrow());
continue;
}
path = Path.Combine(head, name);
}

Expand Down
Loading