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

Skip to content

Commit 60ce28b

Browse files
author
denfromufa
authored
Merge branch 'master' into add_scope
2 parents 497d7aa + d9a3666 commit 60ce28b

10 files changed

Lines changed: 29 additions & 4 deletions

File tree

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
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))

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
1010
### Added
1111
- Added clr.GetClrType (#432)(#433)
1212
- Added `Foo` feature
13+
- Allowed passing None for nullable args (#460)
1314

1415
### Changed
1516

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,6 @@
116116
</PropertyGroup>
117117
<Target Name="AfterBuild">
118118
<Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" />
119-
<Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" />
119+
<!--Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" /-->
120120
</Target>
121121
</Project>

src/runtime/Python.Runtime.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,6 @@
162162
</PropertyGroup>
163163
<Target Name="AfterBuild">
164164
<Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" />
165-
<Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" />
165+
<!--Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" /-->
166166
</Target>
167167
</Project>

src/runtime/converter.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,17 @@ internal static bool ToManagedValue(IntPtr value, Type obType,
318318
return true;
319319
}
320320

321+
if (obType.IsGenericType && obType.GetGenericTypeDefinition() == typeof(Nullable<>))
322+
{
323+
if( value == Runtime.PyNone )
324+
{
325+
result = null;
326+
return true;
327+
}
328+
// Set type to underlying type
329+
obType = obType.GetGenericArguments()[0];
330+
}
331+
321332
if (obType.IsArray)
322333
{
323334
return ToArray(value, obType, out result, setError);

src/testing/Python.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,6 @@
108108
</PropertyGroup>
109109
<Target Name="AfterBuild">
110110
<Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(SolutionDir)\src\tests\fixtures" />
111-
<Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" />
111+
<!--Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" /-->
112112
</Target>
113113
</Project>

src/testing/conversiontest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ public ConversionTest()
3232

3333
public byte[] ByteArrayField;
3434
public sbyte[] SByteArrayField;
35+
36+
public T? Echo<T>(T? arg) where T: struct {
37+
return arg;
38+
}
39+
3540
}
3641

42+
3743

3844
public interface ISpam
3945
{

src/tests/test_conversion.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,8 @@ def test_enum_conversion():
641641

642642
def test_null_conversion():
643643
"""Test null conversion."""
644+
import System
645+
644646
ob = ConversionTest()
645647

646648
ob.StringField = None
@@ -652,6 +654,10 @@ def test_null_conversion():
652654
ob.SpamField = None
653655
assert ob.SpamField is None
654656

657+
pi = 22/7
658+
assert ob.Echo[System.Double](pi) == pi
659+
assert ob.Echo[System.DateTime](None) is None
660+
655661
# Primitive types and enums should not be set to null.
656662

657663
with pytest.raises(TypeError):

tools/nuget/nuget.exe

322 KB
Binary file not shown.

0 commit comments

Comments
 (0)