@@ -939,7 +939,7 @@ public override bool TryGetMember(GetMemberBinder binder, out object result)
939
939
{
940
940
if ( this . HasAttr ( binder . Name ) )
941
941
{
942
- result = this . GetAttr ( binder . Name ) ;
942
+ result = CheckNone ( this . GetAttr ( binder . Name ) ) ;
943
943
return true ;
944
944
}
945
945
else
@@ -999,7 +999,7 @@ public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, o
999
999
try
1000
1000
{
1001
1001
GetArgs ( args , out pyargs , out kwargs ) ;
1002
- result = InvokeMethod ( binder . Name , pyargs , kwargs ) ;
1002
+ result = CheckNone ( InvokeMethod ( binder . Name , pyargs , kwargs ) ) ;
1003
1003
}
1004
1004
finally
1005
1005
{
@@ -1023,7 +1023,7 @@ public override bool TryInvoke(InvokeBinder binder, object[] args, out object re
1023
1023
try
1024
1024
{
1025
1025
GetArgs ( args , out pyargs , out kwargs ) ;
1026
- result = Invoke ( pyargs , kwargs ) ;
1026
+ result = CheckNone ( Invoke ( pyargs , kwargs ) ) ;
1027
1027
}
1028
1028
finally
1029
1029
{
@@ -1133,10 +1133,26 @@ public override bool TryBinaryOperation(BinaryOperationBinder binder, Object arg
1133
1133
result = null ;
1134
1134
return false ;
1135
1135
}
1136
- result = new PyObject ( res ) ;
1136
+ result = CheckNone ( new PyObject ( res ) ) ;
1137
+
1137
1138
return true ;
1138
1139
}
1139
1140
1141
+ // Workaround for https://bugzilla.xamarin.com/show_bug.cgi?id=41509
1142
+ // See https://github.com/pythonnet/pythonnet/pull/219
1143
+ private static object CheckNone ( PyObject pyObj )
1144
+ {
1145
+ if ( pyObj != null )
1146
+ {
1147
+ if ( pyObj . obj == Runtime . PyNone )
1148
+ {
1149
+ return null ;
1150
+ }
1151
+ }
1152
+
1153
+ return pyObj ;
1154
+ }
1155
+
1140
1156
public override bool TryUnaryOperation ( UnaryOperationBinder binder , out Object result )
1141
1157
{
1142
1158
int r ;
@@ -1170,7 +1186,7 @@ public override bool TryUnaryOperation(UnaryOperationBinder binder, out Object r
1170
1186
result = null ;
1171
1187
return false ;
1172
1188
}
1173
- result = new PyObject ( res ) ;
1189
+ result = CheckNone ( new PyObject ( res ) ) ;
1174
1190
return true ;
1175
1191
}
1176
1192
}
0 commit comments