Skip to content

Unable to find an entry point named 'PyNumber_Divide' when trying to call an overridden division operator #802

@lostmsu

Description

@lostmsu

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy