8000 ParameterInfo.Name needs to be checked for null before usage (#1375) · pythonnet/pythonnet@4cb551e · GitHub
[go: up one dir, main page]

Skip to content

Commit 4cb551e

Browse files
committed
ParameterInfo.Name needs to be checked for null before usage (#1375)
This occured in trying to use F# code from Python. As the `.Name` property returns `null`, `ContainsKey` fails. Related documentation: https://docs.microsoft.com/en-us/dotnet/api/system.reflection.parameterinfo.name
1 parent 58504e4 commit 4cb551e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed
E340

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
99
## Unreleased
1010

1111
### Fixed
12-
- Fix `object[]` parameters taking precedence when should not in overload resolution
12+
- Fix `object[]` parameters taking precedence when should not in overload resolution
13+
- Empty parameter names (as can be generated from F#) do not cause crashes
1314

1415
## [2.5.1][] - 2020-06-18
1516

src/runtime/methodbinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ static object[] TryConvertArguments(ParameterInfo[] pi, bool paramsArray,
427427
for (int paramIndex = 0; paramIndex < pi.Length; paramIndex++)
428428
{
429429
var parameter = pi[paramIndex];
430-
bool hasNamedParam = kwargDict.ContainsKey(parameter.Name);
430+
bool hasNamedParam = parameter.Name != null ? kwargDict.ContainsKey(parameter.Name) : false;
431431
bool isNewReference = false;
432432

433433
if (paramIndex >= pyArgCount && !(hasNamedParam || (paramsArray && paramIndex == arrayStart)))

0 commit comments

Comments
 (0)
0