allow Python not passing fake arguments for out parameters (#1672)
This commit is contained in:
Родитель
75f4398174
Коммит
f69753c701
|
@ -84,3 +84,4 @@
|
|||
- ([@DanBarzilian](https://github.com/DanBarzilian))
|
||||
- ([@alxnull](https://github.com/alxnull))
|
||||
- ([@gpetrou](https://github.com/gpetrou))
|
||||
- Ehsan Iran-Nejad ([@eirannejad](https://github.com/eirannejad))
|
||||
|
|
|
@ -109,6 +109,7 @@ Instead, `PyIterable` does that.
|
|||
- Empty parameter names (as can be generated from F#) do not cause crashes
|
||||
- Unicode strings with surrogates were truncated when converting from Python
|
||||
- `Reload` mode now supports generic methods (previously Python would stop seeing them after reload)
|
||||
- Temporarily fixed issue resolving method overload when method signature has `out` parameters ([#1672](i1672))
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -881,3 +882,4 @@ This version improves performance on benchmarks significantly compared to 2.3.
|
|||
[i1342]: https://github.com/pythonnet/pythonnet/issues/1342
|
||||
[i238]: https://github.com/pythonnet/pythonnet/issues/238
|
||||
[i1481]: https://github.com/pythonnet/pythonnet/issues/1481
|
||||
[i1672]: https://github.com/pythonnet/pythonnet/pull/1672
|
|
@ -632,6 +632,11 @@ namespace Python.Runtime
|
|||
margs[paramIndex] = defaultArgList[paramIndex - pyArgCount];
|
||||
}
|
||||
|
||||
if (parameter.ParameterType.IsByRef)
|
||||
{
|
||||
outs++;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -817,6 +822,9 @@ namespace Python.Runtime
|
|||
defaultArgList.Add(parameters[v].GetDefaultValue());
|
||||
defaultsNeeded++;
|
||||
}
|
||||
else if (parameters[v].IsOut) {
|
||||
defaultArgList.Add(null);
|
||||
}
|
||||
else if (!paramsArray)
|
||||
{
|
||||
match = false;
|
||||
|
|
|
@ -280,6 +280,16 @@ def test_string_out_params():
|
|||
assert result[1] == "output string"
|
||||
|
||||
|
||||
def test_string_out_params_without_passing_string_value():
|
||||
"""Test use of string out-parameters."""
|
||||
# @eirannejad 2022-01-13
|
||||
result = MethodTest.TestStringOutParams("hi")
|
||||
assert isinstance(result, tuple)
|
||||
assert len(result) == 2
|
||||
assert result[0] is True
|
||||
assert result[1] == "output string"
|
||||
|
||||
|
||||
def test_string_ref_params():
|
||||
"""Test use of string byref parameters."""
|
||||
result = MethodTest.TestStringRefParams("hi", "there")
|
||||
|
@ -308,6 +318,16 @@ def test_value_out_params():
|
|||
MethodTest.TestValueOutParams("hi", None)
|
||||
|
||||
|
||||
def test_value_out_params_without_passing_string_value():
|
||||
"""Test use of string out-parameters."""
|
||||
# @eirannejad 2022-01-13
|
||||
result = MethodTest.TestValueOutParams("hi")
|
||||
assert isinstance(result, tuple)
|
||||
assert len(result) == 2
|
||||
assert result[0] is True
|
||||
assert result[1] == 42
|
||||
|
||||
|
||||
def test_value_ref_params():
|
||||
"""Test use of value type byref parameters."""
|
||||
result = MethodTest.TestValueRefParams("hi", 1)
|
||||
|
@ -336,6 +356,15 @@ def test_object_out_params():
|
|||
assert isinstance(result[1], System.Exception)
|
||||
|
||||
|
||||
def test_object_out_params_without_passing_string_value():
|
||||
"""Test use of object out-parameters."""
|
||||
result = MethodTest.TestObjectOutParams("hi")
|
||||
assert isinstance(result, tuple)
|
||||
assert len(result) == 2
|
||||
assert result[0] is True
|
||||
assert isinstance(result[1], System.Exception)
|
||||
|
||||
|
||||
def test_object_ref_params():
|
||||
"""Test use of object byref parameters."""
|
||||
result = MethodTest.TestObjectRefParams("hi", MethodTest())
|
||||
|
@ -364,6 +393,15 @@ def test_struct_out_params():
|
|||
MethodTest.TestValueRefParams("hi", None)
|
||||
|
||||
|
||||
def test_struct_out_params_without_passing_string_value():
|
||||
"""Test use of struct out-parameters."""
|
||||
result = MethodTest.TestStructOutParams("hi")
|
||||
assert isinstance(result, tuple)
|
||||
assert len(result) == 2
|
||||
assert result[0] is True
|
||||
assert isinstance(result[1], System.Guid)
|
||||
|
||||
|
||||
def test_struct_ref_params():
|
||||
"""Test use of struct byref parameters."""
|
||||
result = MethodTest.TestStructRefParams("hi", System.Guid.NewGuid())
|
||||
|
|
Загрузка…
Ссылка в новой задаче