Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add complex class test #143

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

add complex class test #143

wants to merge 10 commits into from

Conversation

mw66
Copy link
Contributor

@mw66 mw66 commented Dec 19, 2020

This is a bug report actually:

$ cat c.py

c = complex(2,-1)
h = c.__hash__();

print(c)
print(h)

# python output
$ python c.py 
(2-1j)
-2000004   # here!

however, pyd output:

$ dub build
$ ./simple_embedded 
1 + 2
(2-1j)
<method-wrapper '__hash__' of complex object at 0x7fa8c49897d0>  # here!

@mw66
Copy link
Contributor Author

mw66 commented Dec 19, 2020

I just found the work around how to make the pyd call:

    auto h = c.__hash__()();

I think here we should use the python convention:

  c.__hash__;    // return the method-wrapper
  c.__hash__();  // return the result of the function call.

@ariovistus
Copy link
Owner

Ah, yeah, that's kind of annoying. I would certainly like it if I could get D to do as you suggest, but there is no way (or wasn't last time I checked, admittedly a while) to get opDispatch to distinguish between obj.property and obj.property(). So we have this kind of compromise where no parameters are treated as obj.property and presence of parameters are treated as a method call.

@mw66
Copy link
Contributor Author

mw66 commented Dec 20, 2020

OK, I added the work-around, so new user can follow the example to make the call.

@mw66
Copy link
Contributor Author

mw66 commented Mar 10, 2022

@ariovistus: I'm a git idiot, I tried to add python39 support (which I have been used for a year without problem on my local machine), but I messed up my PR and my local branches.

It should be just a single file PR (commit hash 170ac4b) for dub.json:

170ac4b

If you have time, can you separate this file as a single PR and merge it, then we can have python39 support.

Thanks.

@ariovistus
Copy link
Owner

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants