Skip to content

Commit 1d01c45

Browse files
authored
Merge branch 'master' into fix_kwarg_func_resolution
2 parents a1b6c76 + f506d65 commit 1d01c45

File tree

100 files changed

+5842
-2296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+5842
-2296
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ python:
55
- 3.8
66
- 3.7
77
- 3.6
8-
- 3.5
98

109
env:
1110
matrix:
1211
- BUILD_OPTS=--xplat NUNIT_PATH="~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe" RUN_TESTS=dotnet EMBED_TESTS_PATH=netcoreapp2.0_publish/ PERF_TESTS_PATH=net461/
1312
- BUILD_OPTS="" NUNIT_PATH="./packages/NUnit.*/tools/nunit3-console.exe" RUN_TESTS="mono $NUNIT_PATH" EMBED_TESTS_PATH="" PERF_TESTS_PATH=""
13+
- PYTHONNET_SHUTDOWN_MODE="Soft" BUILD_OPTS=--xplat NUNIT_PATH="~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe" RUN_TESTS=dotnet EMBED_TESTS_PATH=netcoreapp2.0_publish/ PERF_TESTS_PATH=net461/
14+
- PYTHONNET_SHUTDOWN_MODE="Soft" BUILD_OPTS="" NUNIT_PATH="./packages/NUnit.*/tools/nunit3-console.exe" RUN_TESTS="mono $NUNIT_PATH" EMBED_TESTS_PATH="" PERF_TESTS_PATH=""
1415

1516
global:
1617
- LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so

AUTHORS.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,22 @@
2020
- Alexandre Catarino([@AlexCatarino](https://github.com/AlexCatarino))
2121
- Andrey Sant'Anna ([@andreydani](https://github.com/andreydani))
2222
- Arvid JB ([@ArvidJB](https://github.com/ArvidJB))
23+
- Avinash Maddikonda ([@SFM61319](https://github.com/SFM61319))
2324
- Benoît Hudson ([@benoithudson](https://github.com/benoithudson))
2425
- Bradley Friedman ([@leith-bartrich](https://github.com/leith-bartrich))
2526
- Callum Noble ([@callumnoble](https://github.com/callumnoble))
2627
- Christian Heimes ([@tiran](https://github.com/tiran))
2728
- Christoph Gohlke ([@cgohlke](https://github.com/cgohlke))
2829
- Christopher Bremner ([@chrisjbremner](https://github.com/chrisjbremner))
2930
- Christopher Pow ([@christopherpow](https://github.com/christopherpow))
31+
- Daniel Abrahamsson ([@danabr](https://github.com/danabr))
3032
- Daniel Fernandez ([@fdanny](https://github.com/fdanny))
3133
- Daniel Santana ([@dgsantana](https://github.com/dgsantana))
3234
- Dave Hirschfeld ([@dhirschfeld](https://github.com/dhirschfeld))
3335
- David Lassonde ([@lassond](https://github.com/lassond))
3436
- David Lechner ([@dlech](https://github.com/dlech))
3537
- Dmitriy Se ([@dmitriyse](https://github.com/dmitriyse))
38+
- Félix Bourbonnais ([@BadSingleton](https://github.com/BadSingleton))
3639
- Florian Treurniet ([@ftreurni](https://github.com/ftreurni))
3740
- He-chien Tsai ([@t3476](https://github.com/t3476))
3841
- Inna Wiesel ([@inna-w](https://github.com/inna-w))
@@ -64,14 +67,16 @@
6467
- William Sardar ([@williamsardar])(https://github.com/williamsardar)
6568
- Xavier Dupré ([@sdpython](https://github.com/sdpython))
6669
- Zane Purvis ([@zanedp](https://github.com/zanedp))
70+
- ([@amos402]https://github.com/amos402)
6771
- ([@bltribble](https://github.com/bltribble))
6872
- ([@civilx64](https://github.com/civilx64))
6973
- ([@GSPP](https://github.com/GSPP))
7074
- ([@omnicognate](https://github.com/omnicognate))
7175
- ([@OneBlue](https://github.com/OneBlue))
7276
- ([@rico-chet](https://github.com/rico-chet))
7377
- ([@rmadsen-ks](https://github.com/rmadsen-ks))
78+
- ([@SnGmng](https://github.com/SnGmng))
7479
- ([@stonebig](https://github.com/stonebig))
7580
- ([@testrunner123](https://github.com/testrunner123))
7681
- ([@DanBarzilian](https://github.com/DanBarzilian))
77-
82+
- ([@alxnull](https://github.com/alxnull))

CHANGELOG.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,29 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
1010
### Added
1111

1212
### Changed
13-
- Drop support for Python 2
13+
- Drop support for Python 2, 3.4, and 3.5
14+
- `clr.AddReference` may now throw errors besides `FileNotFoundException`, that provide more
15+
details about the cause of the failure
16+
- `clr.AddReference` no longer adds ".dll" implicitly
17+
- `PyIter(PyObject)` constructor replaced with static `PyIter.GetIter(PyObject)` method
18+
- Return values from .NET methods that return an interface are now automatically
19+
wrapped in that interface. This is a breaking change for users that rely on being
20+
able to access members that are part of the implementation class, but not the
21+
interface. Use the new __implementation__ or __raw_implementation__ properties to
22+
if you need to "downcast" to the implementation class.
1423

1524
### Fixed
1625

1726
- Fix incorrect dereference of wrapper object in `tp_repr`, which may result in a program crash
1827
- Fix incorrect dereference in params array handling
19-
- Fixes issue with function resolution when calling overloaded function with keyword arguments from python ([#1097][i1097])
28+
- Fixes issue with function resolution when calling overloaded function with keyword arguments from python ([#1097][i1097])
29+
- Fix `object[]` parameters taking precedence when should not in overload resolution
30+
- Fixed a bug where all .NET class instances were considered Iterable
31+
- Fix incorrect choice of method to invoke when using keyword arguments.
32+
- Fix non-delegate types incorrectly appearing as callable.
33+
- Indexers can now be used with interface objects
34+
- Fixed a bug where indexers could not be used if they were inherited
35+
- Made it possible to use `__len__` also on `ICollection<>` interface objects
2036

2137
## [2.5.0][] - 2020-06-14
2238

@@ -36,6 +52,7 @@ This version improves performance on benchmarks significantly compared to 2.3.
3652
- Support for Python 3.8
3753
- Codecs as the designated way to handle automatic conversions between
3854
.NET and Python types
55+
- Added Python 3 buffer api support and PyBuffer interface for fast byte and numpy array read/write ([#980][p980])
3956

4057
### Changed
4158

@@ -98,6 +115,7 @@ This version improves performance on benchmarks significantly compared to 2.3.
98115
- PythonEngine.Intialize will now call `Py_InitializeEx` with a default value of 0, so signals will not be configured by default on embedding. This is different from the previous behaviour, where `Py_Initialize` was called instead, which sets initSigs to 1. ([#449][i449])
99116
- Refactored MethodBinder.Bind in preparation to make it extensible (#829)
100117
- Look for installed Windows 10 sdk's during installation instead of relying on specific versions.
118+
- Remove `LoadLibrary` call. ([#880][p880])
101119

102120
### Fixed
103121

README.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@ provides a powerful application scripting tool for .NET developers. It
1414
allows Python code to interact with the CLR, and may also be used to
1515
embed Python into a .NET application.
1616

17+
.. note::
18+
The master branch of this repository tracks the ongoing development of version 3.0.
19+
Backports of patches to 2.5 are tracked in the
20+
`backports-2.5 branch <https://github.com/pythonnet/pythonnet/tree/backports-2.5>`_.
21+
1722
Calling .NET code from Python
1823
-----------------------------
1924

2025
Python.NET allows CLR namespaces to be treated essentially as Python packages.
2126

22-
.. code-block::
27+
.. code-block:: python
2328
2429
import clr
2530
from System import String
@@ -28,7 +33,7 @@ Python.NET allows CLR namespaces to be treated essentially as Python packages.
2833
To load an assembly, use the ``AddReference`` function in the ``clr``
2934
module:
3035

31-
.. code-block::
36+
.. code-block:: python
3237
3338
import clr
3439
clr.AddReference("System.Windows.Forms")
@@ -80,7 +85,7 @@ Example
8085
8186
Output:
8287

83-
.. code::
88+
.. code:: csharp
8489
8590
1.0
8691
-0.958924274663

appveyor.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@ environment:
1616

1717
matrix:
1818
- PYTHON_VERSION: 3.8
19-
BUILD_OPTS: --xplat
2019
- PYTHON_VERSION: 3.7
2120
BUILD_OPTS: --xplat
2221
- PYTHON_VERSION: 3.6
2322
BUILD_OPTS: --xplat
24-
- PYTHON_VERSION: 3.5
25-
BUILD_OPTS: --xplat
2623
- PYTHON_VERSION: 3.8
2724
- PYTHON_VERSION: 3.7
2825
- PYTHON_VERSION: 3.6
29-
- PYTHON_VERSION: 3.5
30-
26+
- PYTHON_VERSION: 3.7
27+
PYTHONNET_SHUTDOWN_MODE: Soft
28+
- PYTHON_VERSION: 3.8
29+
PYTHONNET_SHUTDOWN_MODE: Soft
3130
init:
3231
# Update Environment Variables based on matrix/platform
3332
- set PY_VER=%PYTHON_VERSION:.=%
@@ -40,6 +39,7 @@ init:
4039
install:
4140
- python -m pip install -U pip
4241
- pip install --upgrade -r requirements.txt --quiet
42+
- pip install pycparser --quiet
4343

4444
# Install OpenCover. Can't put on `packages.config`, not Mono compatible
4545
- .\tools\nuget\nuget.exe install OpenCover -OutputDirectory packages -Verbosity quiet
@@ -51,7 +51,7 @@ build_script:
5151
- coverage run setup.py bdist_wheel %BUILD_OPTS%
5252

5353
test_script:
54-
- pip install --find-links=.\dist\ pythonnet
54+
- pip install --no-index --find-links=.\dist\ pythonnet
5555
- ps: .\ci\appveyor_run_tests.ps1
5656

5757
on_finish:

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,6 @@ def run(self):
637637
"License :: OSI Approved :: MIT License",
638638
"Programming Language :: C#",
639639
"Programming Language :: Python :: 3",
640-
"Programming Language :: Python :: 3.5",
641640
"Programming Language :: Python :: 3.6",
642641
"Programming Language :: Python :: 3.7",
643642
"Programming Language :: Python :: 3.8",

src/embed_tests/Python.EmbeddingTest.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
<Compile Include="TestFinalizer.cs" />
9898
<Compile Include="TestInstanceWrapping.cs" />
9999
<Compile Include="TestPyAnsiString.cs" />
100+
<Compile Include="TestPyBuffer.cs" />
100101
<Compile Include="TestPyFloat.cs" />
101102
<Compile Include="TestPyInt.cs" />
102103
<Compile Include="TestPyList.cs" />

src/embed_tests/TestConverter.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
4+
35
using NUnit.Framework;
6+
47
using Python.Runtime;
58

9+
using PyRuntime = Python.Runtime.Runtime;
10+
611
namespace Python.EmbeddingTest
712
{
813
public class TestConverter
914
{
15+
static readonly Type[] _numTypes = new Type[]
16+
{
17+
typeof(short),
18+
typeof(ushort),
19+
typeof(int),
20+
typeof(uint),
21+
typeof(long),
22+
typeof(ulong)
23+
};
24+
1025
[OneTimeSetUp]
1126
public void SetUp()
1227
{
@@ -47,6 +62,60 @@ public void TestConvertDoubleToManaged(
4762
Assert.IsTrue(((double) convertedValue).Equals(testValue));
4863
}
4964

65+
[Test]
66+
public void CovertTypeError()
67+
{
68+
Type[] floatTypes = new Type[]
69+
{
70+
typeof(float),
71+
typeof(double)
72+
};
73+
using (var s = new PyString("abc"))
74+
{
75+
foreach (var type in _numTypes.Union(floatTypes))
76+
{
77+
object value;
78+
try
79+
{
80+
bool res = Converter.ToManaged(s.Handle, type, out value, true);
81+
Assert.IsFalse(res);
82+
var bo = Exceptions.ExceptionMatches(Exceptions.TypeError);
83+
Assert.IsTrue(Exceptions.ExceptionMatches(Exceptions.TypeError)
84+
|| Exceptions.ExceptionMatches(Exceptions.ValueError));
85+
}
86+
finally
87+
{
88+
Exceptions.Clear();
89+
}
90+
}
91+
}
92+
}
93+
94+
[Test]
95+
public void ConvertOverflow()
96+
{
97+
using (var num = new PyLong(ulong.MaxValue))
98+
{
99+
IntPtr largeNum = PyRuntime.PyNumber_Add(num.Handle, num.Handle);
100+
try
101+
{
102+
object value;
103+
foreach (var type in _numTypes)
104+
{
105+
bool res = Converter.ToManaged(largeNum, type, out value, true);
106+
Assert.IsFalse(res);
107+
Assert.IsTrue(Exceptions.ExceptionMatches(Exceptions.OverflowError));
108+
Exceptions.Clear();
109+
}
110+
}
111+
finally
112+
{
113+
Exceptions.Clear();
114+
PyRuntime.XDecref(largeNum);
115+
}
116+
}
117+
}
118+
50119
[Test]
51120
public void RawListProxy()
52121
{

0 commit comments

Comments
 (0)