Skip to content

Commit 10d7ef4

Browse files
authored
Merge branch 'master' into 2574-StackOverFlowExceptionOnSuperMethodCallFix
2 parents 98a740e + fc6c9e9 commit 10d7ef4

27 files changed

+857
-472
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Line endings normalization
2+
fd7c7e1cbd8e1d7bdb2ec2423c3cf9f95a3abed1

.github/workflows/main.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ jobs:
3636

3737
- category: macos
3838
platform: x64
39-
instance: macos-13
39+
instance: macos-14
4040

41-
python: ["3.10", "3.11", "3.12", "3.13"]
41+
- category: macos
42+
platform: arm64
43+
instance: macos-14-arm64
44+
45+
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
4246

4347
steps:
4448
- name: Set Environment on macOS
@@ -53,7 +57,7 @@ jobs:
5357
- name: Setup .NET
5458
uses: actions/setup-dotnet@v5
5559
with:
56-
dotnet-version: '8.0.x'
60+
dotnet-version: '10.0.x'
5761

5862
- name: Set up Python ${{ matrix.python }}
5963
uses: astral-sh/setup-uv@v7
@@ -77,7 +81,7 @@ jobs:
7781
MONO_THREADS_SUSPEND: preemptive # https://github.com/mono/mono/issues/21466
7882

7983
- name: Embedding tests (.NET Core)
80-
run: dotnet test --runtime any-${{ matrix.os.platform }} --framework net8.0 --logger "console;verbosity=detailed" src/embed_tests/
84+
run: dotnet test --runtime any-${{ matrix.os.platform }} --framework net10.0 --logger "console;verbosity=detailed" src/embed_tests/
8185
if: always()
8286

8387
- name: Python Tests (Mono)

doc/make.bat

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
@ECHO OFF
2-
3-
pushd %~dp0
4-
5-
REM Command file for Sphinx documentation
6-
7-
if "%SPHINXBUILD%" == "" (
8-
set SPHINXBUILD=sphinx-build
9-
)
10-
set SOURCEDIR=source
11-
set BUILDDIR=build
12-
13-
%SPHINXBUILD% >NUL 2>NUL
14-
if errorlevel 9009 (
15-
echo.
16-
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17-
echo.installed, then set the SPHINXBUILD environment variable to point
18-
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19-
echo.may add the Sphinx directory to PATH.
20-
echo.
21-
echo.If you don't have Sphinx installed, grab it from
22-
echo.https://www.sphinx-doc.org/
23-
exit /b 1
24-
)
25-
26-
if "%1" == "" goto help
27-
28-
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29-
goto end
30-
31-
:help
32-
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33-
34-
:end
35-
popd
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies = [
1313
"clr_loader>=0.2.7,<0.3.0"
1414
]
1515

16-
requires-python = ">=3.10, <3.14"
16+
requires-python = ">=3.10, <3.15"
1717

1818
classifiers = [
1919
"Development Status :: 5 - Production/Stable",

requirements.txt

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/embed_tests/Python.EmbeddingTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;net8.0</TargetFrameworks>
4+
<TargetFrameworks>net472;net10.0</TargetFrameworks>
55
<AssemblyOriginatorKeyFile>..\pythonnet.snk</AssemblyOriginatorKeyFile>
66
<SignAssembly>true</SignAssembly>
77
</PropertyGroup>

src/python_tests_runner/Python.PythonTestsRunner.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;net8.0</TargetFrameworks>
4+
<TargetFrameworks>net472;net10.0</TargetFrameworks>
55
</PropertyGroup>
66

77
<ItemGroup>

src/runtime/AssemblyManager.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ private static void AssemblyLoadHandler(object ob, AssemblyLoadEventArgs args)
123123

124124
internal static AssemblyName? TryParseAssemblyName(string name)
125125
{
126+
// workaround for https://github.com/dotnet/runtime/issues/123951
127+
if (name.IndexOfAny(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }) >= 0)
128+
{
129+
return null;
130+
}
126131
try
127132
{
128133
return new AssemblyName(name);
Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1-
using System;
2-
using System.Collections.Generic;
3-
4-
namespace Python.Runtime.Codecs
5-
{
6-
public class IterableDecoder : IPyObjectDecoder
7-
{
8-
internal static bool IsIterable(Type targetType)
9-
{
10-
//if it is a plain IEnumerable, we can decode it using sequence protocol.
11-
if (targetType == typeof(System.Collections.IEnumerable))
12-
return true;
13-
14-
if (!targetType.IsGenericType)
15-
return false;
16-
17-
return targetType.GetGenericTypeDefinition() == typeof(IEnumerable<>);
18-
}
19-
20-
internal static bool IsIterable(PyType objectType)
21-
{
22-
return objectType.HasAttr("__iter__");
23-
}
24-
25-
public bool CanDecode(PyType objectType, Type targetType)
26-
{
27-
return IsIterable(objectType) && IsIterable(targetType);
28-
}
29-
30-
public bool TryDecode<T>(PyObject pyObj, out T value)
31-
{
32-
//first see if T is a plan IEnumerable
33-
if (typeof(T) == typeof(System.Collections.IEnumerable))
34-
{
35-
object enumerable = new CollectionWrappers.IterableWrapper<object>(pyObj);
36-
value = (T)enumerable;
37-
return true;
38-
}
39-
40-
var elementType = typeof(T).GetGenericArguments()[0];
41-
var collectionType = typeof(CollectionWrappers.IterableWrapper<>).MakeGenericType(elementType);
42-
43-
var instance = Activator.CreateInstance(collectionType, new[] { pyObj });
44-
value = (T)instance;
45-
return true;
46-
}
47-
48-
public static IterableDecoder Instance { get; } = new IterableDecoder();
49-
50-
public static void Register()
51-
{
52-
PyObjectConversions.RegisterDecoder(Instance);
53-
}
54-
}
55-
}
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace Python.Runtime.Codecs
5+
{
6+
public class IterableDecoder : IPyObjectDecoder
7+
{
8+
internal static bool IsIterable(Type targetType)
9+
{
10+
//if it is a plain IEnumerable, we can decode it using sequence protocol.
11+
if (targetType == typeof(System.Collections.IEnumerable))
12+
return true;
13+
14+
if (!targetType.IsGenericType)
15+
return false;
16+
17+
return targetType.GetGenericTypeDefinition() == typeof(IEnumerable<>);
18+
}
19+
20+
internal static bool IsIterable(PyType objectType)
21+
{
22+
return objectType.HasAttr("__iter__");
23+
}
24+
25+
public bool CanDecode(PyType objectType, Type targetType)
26+
{
27+
return IsIterable(objectType) && IsIterable(targetType);
28+
}
29+
30+
public bool TryDecode<T>(PyObject pyObj, out T value)
31+
{
32+
//first see if T is a plan IEnumerable
33+
if (typeof(T) == typeof(System.Collections.IEnumerable))
34+
{
35+
object enumerable = new CollectionWrappers.IterableWrapper<object>(pyObj);
36+
value = (T)enumerable;
37+
return true;
38+
}
39+
40+
var elementType = typeof(T).GetGenericArguments()[0];
41+
var collectionType = typeof(CollectionWrappers.IterableWrapper<>).MakeGenericType(elementType);
42+
43+
var instance = Activator.CreateInstance(collectionType, new[] { pyObj });
44+
value = (T)instance;
45+
return true;
46+
}
47+
48+
public static IterableDecoder Instance { get; } = new IterableDecoder();
49+
50+
public static void Register()
51+
{
52+
PyObjectConversions.RegisterDecoder(Instance);
53+
}
54+
}
55+
}

src/runtime/Codecs/ListDecoder.cs

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
using System;
2-
using System.Collections.Generic;
3-
4-
namespace Python.Runtime.Codecs
5-
{
6-
public class ListDecoder : IPyObjectDecoder
7-
{
8-
private static bool IsList(Type targetType)
9-
{
10-
if (!targetType.IsGenericType)
11-
return false;
12-
13-
return targetType.GetGenericTypeDefinition() == typeof(IList<>);
14-
}
15-
16-
private static bool IsList(PyType objectType)
17-
{
18-
//TODO accept any python object that implements the sequence and list protocols
19-
//must implement sequence protocol to fully implement list protocol
20-
//if (!SequenceDecoder.IsSequence(objectType)) return false;
21-
22-
//returns wheter the type is a list.
23-
return PythonReferenceComparer.Instance.Equals(objectType, Runtime.PyListType);
24-
}
25-
26-
public bool CanDecode(PyType objectType, Type targetType)
27-
{
28-
return IsList(objectType) && IsList(targetType);
29-
}
30-
31-
public bool TryDecode<T>(PyObject pyObj, out T value)
32-
{
33-
if (pyObj == null) throw new ArgumentNullException(nameof(pyObj));
34-
35-
var elementType = typeof(T).GetGenericArguments()[0];
36-
Type collectionType = typeof(CollectionWrappers.ListWrapper<>).MakeGenericType(elementType);
37-
38-
var instance = Activator.CreateInstance(collectionType, new[] { pyObj });
39-
value = (T)instance;
40-
return true;
41-
}
42-
43-
public static ListDecoder Instance { get; } = new ListDecoder();
44-
45-
public static void Register()
46-
{
47-
PyObjectConversions.RegisterDecoder(Instance);
48-
}
49-
}
50-
}
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace Python.Runtime.Codecs
5+
{
6+
public class ListDecoder : IPyObjectDecoder
7+
{
8+
private static bool IsList(Type targetType)
9+
{
10+
if (!targetType.IsGenericType)
11+
return false;
12+
13+
return targetType.GetGenericTypeDefinition() == typeof(IList<>);
14+
}
15+
16+
private static bool IsList(PyType objectType)
17+
{
18+
//TODO accept any python object that implements the sequence and list protocols
19+
//must implement sequence protocol to fully implement list protocol
20+
//if (!SequenceDecoder.IsSequence(objectType)) return false;
21+
22+
//returns wheter the type is a list.
23+
return PythonReferenceComparer.Instance.Equals(objectType, Runtime.PyListType);
24+
}
25+
26+
public bool CanDecode(PyType objectType, Type targetType)
27+
{
28+
return IsList(objectType) && IsList(targetType);
29+
}
30+
31+
public bool TryDecode<T>(PyObject pyObj, out T value)
32+
{
33+
if (pyObj == null) throw new ArgumentNullException(nameof(pyObj));
34+
35+
var elementType = typeof(T).GetGenericArguments()[0];
36+
Type collectionType = typeof(CollectionWrappers.ListWrapper<>).MakeGenericType(elementType);
37+
38+
var instance = Activator.CreateInstance(collectionType, new[] { pyObj });
39+
value = (T)instance;
40+
return true;
41+
}
42+
43+
public static ListDecoder Instance { get; } = new ListDecoder();
44+
45+
public static void Register()
46+
{
47+
PyObjectConversions.RegisterDecoder(Instance);
48+
}
49+
}
50+
}

0 commit comments

Comments
 (0)