Skip to content

bpo-37499: add test functions for each calling convention #14795

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

Closed
wants to merge 3 commits into from

Conversation

jdemeyer
Copy link
Contributor

@jdemeyer jdemeyer commented Jul 16, 2019

@mangrisano
Copy link
Contributor

/cc @encukou @vstinner

@jdemeyer
Copy link
Contributor Author

jdemeyer commented Aug 4, 2019

CC @pganssle

Copy link
Member

@pganssle pganssle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long delay in reviewing this.

I am ever-so-slightly worried that we're moving these all over to being method calls instead of function calls, but I can't think of any good reason why it would undermine the point of the tests.

I personally like the namespacing of a method, so I say leave it as is.

Also, it's not causing any new failures, but test_gdb is now spitting out a bunch of errors or warnings or something that seem very related:

$ ./python -m test test_gdb
Run tests sequentially
0:00:00 load avg: 1.84 [1/1] test_gdb
Function "CallTest_varargs" not defined.
Function "CallTest_varargs" not defined.
Function "CallTest_varargs_keywords" not defined.
Function "CallTest_varargs_keywords" not defined.
Function "CallTest_fastcall" not defined.
Function "CallTest_fastcall" not defined.
Function "CallTest_fastcall_keywords" not defined.
Function "CallTest_fastcall_keywords" not defined.
Function "CallTest_noargs" not defined.
Function "CallTest_noargs" not defined.
Function "CallTest_onearg" not defined.
Function "CallTest_onearg" not defined.
Function "CallTest_call" not defined.
Function "CallTest_call" not defined.
Function "CallTest_call" not defined.
Function "CallTest_call" not defined.
test_gdb passed in 37 sec 821 ms

== Tests result: SUCCESS ==

1 test OK.

Total duration: 37 sec 828 ms
Tests result: SUCCESS

}

static PyObject *
CallTest_fastcall_keywords(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP 7: Line too long,

Suggested change
CallTest_fastcall_keywords(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
CallTest_fastcall_keywords(PyObject *self, PyObject *const *args,
Py_ssize_t nargs, PyObject *kwnames)

@@ -321,6 +321,9 @@ def static_method():

@cpython_only
class FastCallTests(unittest.TestCase):
from _testcapi import CallTest as C
c = C()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this is actually quite confusing, c and C look very similar, I did not even realize that you were alternating between instance methods and class methods.

Can we use more distinct-looking names for these? How about:

from _testcapi import CallTest as CT
ci = CT() 

Something like this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer CallTest and calltest.

Copy link
Member

@pganssle pganssle Sep 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still find it very hard to visually distinguish between a sea of references like this:

calltest.blah
CallTest.blah
calltest.blah

Can it be something like ct_inst and CallTest?

ct_inst.blah
CallTest.blah
ct_inst.blah

Even call_test and CallTest would be fine:

call_test.blah
CallTest.blah
call_test.blah

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@encukou
Copy link
Member

encukou commented Sep 9, 2019

I hope to look at this at this week's sprint. To make it faster, I'll push changes directly to this branch.
@jdemeyer, let me know if you want more back-and-forth; it's always possible to revert my changes.

@jdemeyer
Copy link
Contributor Author

jdemeyer commented Sep 9, 2019

Also, it's not causing any new failures, but test_gdb is now spitting out a bunch of errors or warnings or something that seem very related:

This has to do with the fact that we're importing these functions from an external module (_testcapimodule) instead of being compiled-in functions. I don't know how to suppress these warnings.

@encukou
Copy link
Member

encukou commented Sep 9, 2019

I did something similar – testing that C callables can be called fro Python code. See GH-15776
I have merged code from here into there, but used my code for the GDB test to cover the various functions/methods/classmethods.
If you have some time, could you there & see if it makes sense?

@jdemeyer
Copy link
Contributor Author

jdemeyer commented Sep 9, 2019

Regarding the formatting in Lib/test/test_call.py: I think this is a case where the wrongly-formatted original is much more readable than the changed PEP-8-compliant variant.

@encukou
Copy link
Member

encukou commented Sep 10, 2019

That's one point where I disagree. The aligned code looks neater, but IMO it doesn't help readability much, and makes larger diffs wen it needs to be updated.

pganssle pushed a commit to encukou/cpython that referenced this pull request Sep 10, 2019
Adapted by Petr Viktorin from python#14795
All bugs are Petr's :)
@pganssle
Copy link
Member

Closing this one as superceded by #15776, which includes elements of this PR and some additional tests.

Thanks @jdemeyer!

@pganssle pganssle closed this Sep 10, 2019
@jdemeyer jdemeyer deleted the bpo37499 branch September 10, 2019 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting changes skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants