Skip to content

Commit 45eaa72

Browse files
authored
Merge branch 'master' into coreclr
2 parents 5ff01dc + 25e66f0 commit 45eaa72

28 files changed

+1716
-182
lines changed

AUTHORS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@
1919
- Christopher Pow ([@christopherpow](https://github.com/christopherpow))
2020
- Daniel Fernandez ([@fdanny](https://github.com/fdanny))
2121
- Daniel Santana ([@dgsantana](https://github.com/dgsantana))
22+
- Dave Hirschfeld ([@dhirschfeld](https://github.com/dhirschfeld))
2223
- David Lechner ([@dlech](https://github.com/dlech))
2324
- Dmitriy Se ([@dmitriyse](https://github.com/dmitriyse))
2425
- He-chien Tsai ([@t3476](https://github.com/t3476))
2526
- Jeff Reback ([@jreback](https://github.com/jreback))
2627
- Joe Frayne ([@jfrayne](https://github.com/jfrayne))
2728
- John Burnett ([@johnburnett](https://github.com/johnburnett))
2829
- Luke Stratman ([@lstratman](https://github.com/lstratman))
30+
- Konstantin Posudevskiy ([@konstantin-posudevskiy](https://github.com/konstantin-posudevskiy))
2931
- Matthias Dittrich ([@matthid](https://github.com/matthid))
3032
- Patrick Stewart ([@patstew](https://github.com/patstew))
3133
- Raphael Nestler ([@rnestler](https://github.com/rnestler))
34+
- Rickard Holmberg ([@rickardraysearch](https://github.com/rickardraysearch))
3235
- Sam Winstanley ([@swinstanley](https://github.com/swinstanley))
3336
- Sean Freitag ([@cowboygneox](https://github.com/cowboygneox))
3437
- Serge Weinstock ([@sweinst](https://github.com/sweinst))
@@ -42,3 +45,5 @@
4245
- ([@rico-chet](https://github.com/rico-chet))
4346
- ([@rmadsen-ks](https://github.com/rmadsen-ks))
4447
- ([@stonebig](https://github.com/stonebig))
48+
- ([@testrunner123](https://github.com/testrunner123))
49+

CHANGELOG.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
99
- Added VS 2017 build with net40 and NetStandard 1.5 targets
1010

1111
### Added
12-
- Added clr.GetClrType (#432)(#433)
13-
- Added `Foo` feature
12+
- Added `clr.GetClrType` (#432, #433)
13+
- Allowed passing `None` for nullable args (#460)
14+
- Added keyword arguments based on C# syntax for calling CPython methods (#461)
1415

1516
### Changed
1617

17-
- Changed `Bar` feature
18-
1918
### Fixed
2019

2120
- Fixed Visual Studio 2017 compat (#434) for setup.py
22-
- Fixed `FooBar` bug
21+
- Fixed crash on exit of the Python interpreter if a python class
22+
derived from a .NET class has a `__namespace__` or `__assembly__`
23+
attribute (#481)
24+
- Fixed conversion of 'float' and 'double' values (#486)
25+
- Fixed 'clrmethod' for python 2 (#492)
26+
- Fixed double calling of constructor when deriving from .NET class (#495)
27+
2328

2429
## [2.3.0][] - 2017-03-11
2530

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# pythonnet - Python for .NET
22

3+
[![Join the chat at https://gitter.im/pythonnet/pythonnet](https://badges.gitter.im/pythonnet/pythonnet.svg)](https://gitter.im/pythonnet/pythonnet?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4+
35
[![appveyor shield][]](https://ci.appveyor.com/project/pythonnet/pythonnet/branch/master)
46
[![travis shield][]](https://travis-ci.org/pythonnet/pythonnet)
57
[![codecov shield][]](https://codecov.io/github/pythonnet/pythonnet)
@@ -42,7 +44,7 @@ from System.Windows.Forms import Form
4244
a `using (Py.GIL()) {/* Your code here */}` block.
4345
- Import python modules using `dynamic mod = Py.Import("mod")`,
4446
then you can call functions as normal, eg `mod.func(args)`.
45-
- Use `mod.func(args, Py.kw("keywordargname", keywordargvalue))`
47+
- Use `mod.func(args, Py.kw("keywordargname", keywordargvalue))` or `mod.func(args, keywordargname=keywordargvalue)`
4648
to apply keyword arguments.
4749
- All python objects should be declared as `dynamic` type.
4850
- Mathematical operations involving python and literal/managed types must
@@ -67,7 +69,7 @@ static void Main(string[] args)
6769
dynamic a = np.array(new List<float> { 1, 2, 3 });
6870
Console.WriteLine(a.dtype);
6971

70-
dynamic b = np.array(new List<float> { 6, 5, 4 }, Py.kw("dtype", np.int32));
72+
dynamic b = np.array(new List<float> { 6, 5, 4 }, dtype=np.int32);
7173
Console.WriteLine(b.dtype);
7274

7375
Console.WriteLine(a * b);
@@ -87,6 +89,10 @@ int32
8789
[ 6. 10. 12.]
8890
```
8991

92+
Information on installation, FAQ, troubleshooting, debugging, and projects using pythonnet can be found in the Wiki:
93+
94+
https://github.com/pythonnet/pythonnet/wiki
95+
9096
[appveyor shield]: https://img.shields.io/appveyor/ci/pythonnet/pythonnet/master.svg?label=AppVeyor
9197

9298
[codecov shield]: https://img.shields.io/codecov/c/github/pythonnet/pythonnet/master.svg?label=Codecov

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def build_extension(self, ext):
209209
'pythonnet.sln',
210210
'/p:Configuration={}'.format(_config),
211211
'/p:Platform={}'.format(ARCH),
212-
'/p:DefineConstants="{}"'.format(','.join(defines)),
212+
'/p:DefineConstants="{}"'.format('%3B'.join(defines)),
213213
'/p:PythonBuildDir="{}"'.format(os.path.abspath(dest_dir)),
214214
'/p:PythonInteropFile="{}"'.format(os.path.basename(interop_file)),
215215
'/verbosity:{}'.format(VERBOSITY),

src/embed_tests/Python.EmbeddingTest.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -84,6 +84,7 @@
8484
<Compile Include="pyimport.cs" />
8585
<Compile Include="pyinitialize.cs" />
8686
<Compile Include="pyrunstring.cs" />
87+
<Compile Include="TestConverter.cs" />
8788
<Compile Include="TestCustomMarshal.cs" />
8889
<Compile Include="TestExample.cs" />
8990
<Compile Include="TestPyAnsiString.cs" />
@@ -97,7 +98,10 @@
9798
<Compile Include="TestPythonException.cs" />
9899
<Compile Include="TestPythonEngineProperties.cs" />
99100
<Compile Include="TestPyTuple.cs" />
101+
<Compile Include="TestNamedArguments.cs" />
102+
<Compile Include="TestPyWith.cs" />
100103
<Compile Include="TestRuntime.cs" />
104+
<Compile Include="TestPyScope.cs" />
101105
</ItemGroup>
102106
<ItemGroup>
103107
<ProjectReference Include="..\runtime\Python.Runtime.csproj">
@@ -115,6 +119,6 @@
115119
</PropertyGroup>
116120
<Target Name="AfterBuild">
117121
<Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" />
118-
<Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" />
122+
<!--Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" /-->
119123
</Target>
120-
</Project>
124+
</Project>

src/embed_tests/TestConverter.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using NUnit.Framework;
2+
using Python.Runtime;
3+
4+
namespace Python.EmbeddingTest
5+
{
6+
public class TestConverter
7+
{
8+
[OneTimeSetUp]
9+
public void SetUp()
10+
{
11+
PythonEngine.Initialize();
12+
}
13+
14+
[OneTimeTearDown]
15+
public void Dispose()
16+
{
17+
PythonEngine.Shutdown();
18+
}
19+
20+
[Test]
21+
public void TestConvertSingleToManaged(
22+
[Values(float.PositiveInfinity, float.NegativeInfinity, float.MinValue, float.MaxValue, float.NaN,
23+
float.Epsilon)] float testValue)
24+
{
25+
var pyFloat = new PyFloat(testValue);
26+
27+
object convertedValue;
28+
var converted = Converter.ToManaged(pyFloat.Handle, typeof(float), out convertedValue, false);
29+
30+
Assert.IsTrue(converted);
31+
Assert.IsTrue(((float) convertedValue).Equals(testValue));
32+
}
33+
34+
[Test]
35+
public void TestConvertDoubleToManaged(
36+
[Values(double.PositiveInfinity, double.NegativeInfinity, double.MinValue, double.MaxValue, double.NaN,
37+
double.Epsilon)] double testValue)
38+
{
39+
var pyFloat = new PyFloat(testValue);
40+
41+
object convertedValue;
42+
var converted = Converter.ToManaged(pyFloat.Handle, typeof(double), out convertedValue, false);
43+
44+
Assert.IsTrue(converted);
45+
Assert.IsTrue(((double) convertedValue).Equals(testValue));
46+
}
47+
}
48+
}

src/embed_tests/TestNamedArguments.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using System;
2+
using NUnit.Framework;
3+
using Python.Runtime;
4+
5+
namespace Python.EmbeddingTest
6+
{
7+
public class TestNamedArguments
8+
{
9+
[OneTimeSetUp]
10+
public void SetUp()
11+
{
12+
PythonEngine.Initialize();
13+
}
14+
15+
[OneTimeTearDown]
16+
public void Dispose()
17+
{
18+
PythonEngine.Shutdown();
19+
}
20+
21+
/// <summary>
22+
/// Test named arguments support through Py.kw method
23+
/// </summary>
24+
[Test]
25+
public void TestKeywordArgs()
26+
{
27+
dynamic a = CreateTestClass();
28+
var result = (int)a.Test3(2, Py.kw("a4", 8));
29+
30+
Assert.AreEqual(12, result);
31+
}
32+
33+
34+
/// <summary>
35+
/// Test keyword arguments with .net named arguments
36+
/// </summary>
37+
[Test]
38+
public void TestNamedArgs()
39+
{
40+
dynamic a = CreateTestClass();
41+
var result = (int)a.Test3(2, a4: 8);
42+
43+
Assert.AreEqual(12, result);
44+
}
45+
46+
47+
48+
private static PyObject CreateTestClass()
49+
{
50+
var locals = new PyDict();
51+
52+
PythonEngine.Exec(@"
53+
class cmTest3:
54+
def Test3(self, a1 = 1, a2 = 1, a3 = 1, a4 = 1):
55+
return a1 + a2 + a3 + a4
56+
57+
a = cmTest3()
58+
", null, locals.Handle);
59+
60+
return locals.GetItem("a");
61+
}
62+
63+
}
64+
}

0 commit comments

Comments
 (0)