Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e986114

Browse files
committed
Merge remote-tracking branch 'github/master'
2 parents 56c8a39 + 9ebfbde commit e986114

38 files changed

+1013
-97
lines changed

.github/workflows/main.yml

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,35 @@ on:
99
jobs:
1010
build-test:
1111
name: Build and Test
12-
runs-on: ${{ matrix.os }}-latest
12+
runs-on: ${{ matrix.os.instance }}
1313
timeout-minutes: 15
1414

1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
os: [windows, ubuntu, macos]
19-
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
20-
platform: [x64, x86]
21-
exclude:
22-
- os: ubuntu
23-
platform: x86
24-
- os: macos
18+
os:
19+
- category: windows
2520
platform: x86
21+
instance: windows-latest
22+
23+
- category: windows
24+
platform: x64
25+
instance: windows-latest
26+
27+
- category: ubuntu
28+
platform: x64
29+
instance: ubuntu-latest
30+
31+
- category: macos
32+
platform: x64
33+
instance: macos-13
34+
35+
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
2636

2737
steps:
2838
- name: Set Environment on macOS
2939
uses: maxim-lobanov/setup-xamarin@v1
30-
if: ${{ matrix.os == 'macos' }}
40+
if: ${{ matrix.os.category == 'macos' }}
3141
with:
3242
mono-version: latest
3343

@@ -43,7 +53,7 @@ jobs:
4353
uses: actions/setup-python@v2
4454
with:
4555
python-version: ${{ matrix.python }}
46-
architecture: ${{ matrix.platform }}
56+
architecture: ${{ matrix.os.platform }}
4757

4858
- name: Install dependencies
4959
run: |
@@ -55,42 +65,42 @@ jobs:
5565
pip install -v .
5666
5767
- name: Set Python DLL path and PYTHONHOME (non Windows)
58-
if: ${{ matrix.os != 'windows' }}
68+
if: ${{ matrix.os.category != 'windows' }}
5969
run: |
6070
echo PYTHONNET_PYDLL=$(python -m find_libpython) >> $GITHUB_ENV
6171
echo PYTHONHOME=$(python -c 'import sys; print(sys.prefix)') >> $GITHUB_ENV
6272
6373
- name: Set Python DLL path and PYTHONHOME (Windows)
64-
if: ${{ matrix.os == 'windows' }}
74+
if: ${{ matrix.os.category == 'windows' }}
6575
run: |
6676
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append -InputObject "PYTHONNET_PYDLL=$(python -m find_libpython)"
6777
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append -InputObject "PYTHONHOME=$(python -c 'import sys; print(sys.prefix)')"
6878
6979
- name: Embedding tests
70-
run: dotnet test --runtime any-${{ matrix.platform }} --logger "console;verbosity=detailed" src/embed_tests/
80+
run: dotnet test --runtime any-${{ matrix.os.platform }} --logger "console;verbosity=detailed" src/embed_tests/
7181
env:
7282
MONO_THREADS_SUSPEND: preemptive # https://github.com/mono/mono/issues/21466
7383

7484
- name: Python Tests (Mono)
75-
if: ${{ matrix.os != 'windows' }}
85+
if: ${{ matrix.os.category != 'windows' }}
7686
run: pytest --runtime mono
7787

7888
# TODO: Run these tests on Windows x86
7989
- name: Python Tests (.NET Core)
80-
if: ${{ matrix.platform == 'x64' }}
90+
if: ${{ matrix.os.platform == 'x64' }}
8191
run: pytest --runtime coreclr
8292

8393
- name: Python Tests (.NET Framework)
84-
if: ${{ matrix.os == 'windows' }}
94+
if: ${{ matrix.os.category == 'windows' }}
8595
run: pytest --runtime netfx
8696

8797
- name: Python tests run from .NET
88-
run: dotnet test --runtime any-${{ matrix.platform }} src/python_tests_runner/
98+
run: dotnet test --runtime any-${{ matrix.os.platform }} src/python_tests_runner/
8999

90100
- name: Perf tests
91-
if: ${{ (matrix.python == '3.8') && (matrix.platform == 'x64') }}
101+
if: ${{ (matrix.python == '3.8') && (matrix.os.platform == 'x64') }}
92102
run: |
93103
pip install --force --no-deps --target src/perf_tests/baseline/ pythonnet==2.5.2
94-
dotnet test --configuration Release --runtime any-${{ matrix.platform }} --logger "console;verbosity=detailed" src/perf_tests/
104+
dotnet test --configuration Release --runtime any-${{ matrix.os.platform }} --logger "console;verbosity=detailed" src/perf_tests/
95105
96106
# TODO: Run mono tests on Windows?

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,4 @@
8686
- ([@gpetrou](https://github.com/gpetrou))
8787
- Ehsan Iran-Nejad ([@eirannejad](https://github.com/eirannejad))
8888
- ([@legomanww](https://github.com/legomanww))
89+
- ([@gertdreyer](https://github.com/gertdreyer))

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,21 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
99

1010
### Added
1111

12+
- Added `ToPythonAs<T>()` extension method to allow for explicit conversion using a specific type. ([#2311][i2311])
13+
14+
- Added `IComparable` and `IEquatable` implementations to `PyInt`, `PyFloat`, and `PyString`
15+
to compare with primitive .NET types like `long`.
16+
1217
### Changed
18+
- 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`
19+
- Added a post-serialization and a pre-deserialization step callbacks to extend (de)serialization process
20+
- Added an API to stash serialized data on Python capsules
1321

1422
### Fixed
1523

24+
- Fixed RecursionError for reverse operators on C# operable types from python. See #2240
25+
- Fixed crash when .NET event has no `AddMethod`
26+
- Fixed probing for assemblies in `sys.path` failing when a path in `sys.path` has invalid characters. See #2376
1627

1728
## [3.0.3](https://github.com/pythonnet/pythonnet/releases/tag/v3.0.3) - 2023-10-11
1829

@@ -959,3 +970,4 @@ This version improves performance on benchmarks significantly compared to 2.3.
959970
[i238]: https://github.com/pythonnet/pythonnet/issues/238
960971
[i1481]: https://github.com/pythonnet/pythonnet/issues/1481
961972
[i1672]: https://github.com/pythonnet/pythonnet/pull/1672
973+
[i2311]: https://github.com/pythonnet/pythonnet/issues/2311

src/embed_tests/TestConverter.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ public void RawPyObjectProxy()
185185
Assert.AreEqual(pyObject.DangerousGetAddressOrNull(), proxiedHandle);
186186
}
187187

188+
[Test]
189+
public void GenericToPython()
190+
{
191+
int i = 42;
192+
var pyObject = i.ToPythonAs<IConvertible>();
193+
var type = pyObject.GetPythonType();
194+
Assert.AreEqual(nameof(IConvertible), type.Name);
195+
}
196+
188197
// regression for https://github.com/pythonnet/pythonnet/issues/451
189198
[Test]
190199
public void CanGetListFromDerivedClass()

0 commit comments

Comments
 (0)