FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Unable to find an entry point named 'PyNumber_Divide' when trying to call an overridden division operator · Issue #802 · pythonnet/pythonnet · GitHub

Repository navigation

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

Closed

Description

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

Activity

  1. den-run-ai commented on Jan 16, 2019

    Contributor

    @lostmsu there are some other funny things with dynamic - see #86. Can you make sure that this is reproducible without using dynamic in pythonnet?

  2. lostmsu commented on Jan 17, 2019

    MemberAuthor

    @denfromufa I don't think #86 is directly related. The fact that PyNumber_Divide wrapper exists already seems to be an issue on its own.
    Existence of #86 just indicates TryBinaryOperation is very incomplete.

  3. den-run-ai commented on Jan 17, 2019

    Contributor
  4. den-run-ai commented on Jan 17, 2019

    Contributor

    @lostmsu the issue is that python 3 does not have this method, it is only in Python 2:

    https://docs.python.org/2/c-api/number.html#c.PyNumber_Divide

    Instead probably this one should be used:

    https://docs.python.org/3/c-api/number.html#c.PyNumber_TrueDivide

    Let me know if you like to submit a PR?

  5. lostmsu commented on Jan 17, 2019

    MemberAuthor

    @denfromufa I might get to work on this, but not soon enough :(

  6. filmor commented on Jan 18, 2019

    Member

    Ooh, this is a nasty issue, I'll look into it.

  7. self-assigned this
    on Jan 18, 2019
  8. added this to the 2.4.0 milestone on Jan 18, 2019
  9. added a commit that references this issue on Feb 2, 2019
    f27695b
  10. added a commit that references this issue on Feb 25, 2019
    7bc2495
  11. added a commit that references this issue on Jun 17, 2020
    a98099a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL