Environment
- Pythonnet version: 2.3
- Python version: 3.6.6
- Operating System: Windows 10 x64
Details
I was trying to dynamically call overridden division operator:
dynamic tf = Py.Import("tensorflow");
var c = tf.constant(42, tf.float32) / 2;
Traceback:
System.EntryPointNotFoundException: 'Unable to find an entry point named 'PyNumber_Divide' in DLL 'python36'.'
at Python.Runtime.Runtime.PyNumber_Divide(IntPtr o1, IntPtr o2)
at Python.Runtime.PyObject.TryBinaryOperation(BinaryOperationBinder binder, Object arg, Object& result)
at CallSite.Target(Closure , CallSite , Object , Int32 )
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
It works for + 2 in place of / 2, but might affect other operators too.
Workaround
The workaround is to do .__div__(2) instead of / 2