bpo-4260: Document that ctypes.xFUNCTYPE are decorators by andresdelfino · Pull Request #7924 · python/cpython (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation15 Commits4 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
@@ -1582,7 +1599,7 @@ type and the argument types of the function. |
---|
.. function:: CFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False) |
The returned function prototype creates functions that use the standard C |
Returns a function prototype which creates functions that use the standard C |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't make changes irrelevant to bpo-4260.
@@ -1592,7 +1609,7 @@ type and the argument types of the function. |
---|
.. function:: WINFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False) |
Windows only: The returned function prototype creates functions that use the |
Windows only: Returns a function prototype which creates functions that use the |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't make changes irrelevant to bpo-4260.
@@ -1601,9 +1618,12 @@ type and the argument types of the function. |
---|
.. function:: PYFUNCTYPE(restype, *argtypes) |
The returned function prototype creates functions that use the Python calling |
Returns a function prototype which creates functions that use the Python calling |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't make changes irrelevant to bpo-4260.
convention. The function will *not* release the GIL during the call. |
---|
These factory functions can be used as decorator factories, and as such, be applied |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can move this information to the first paragraph of the "Function prototypes" section to make it more discoverable.
Also, we can add a link to the examples from that paragraph.
write:: |
---|
>>> @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int)) |
... def py_cmp_func(*args): |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why didn't you reuse the py_cmp_func
function in line 1008? IMO, the following snippet should work:
@CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int)) def py_cmp_func(a, b): print("py_cmp_func", a[0], b[0]) return a[0] - b[0]
There is even a test for that same function:
@CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int)) |
---|
def cmp_func(a, b): |
return a[0] - b[0] |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed the proposal from David W. Lambert in the issue, but you are right, I tested the decorator with the function from line 1008 and works as well.
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.
I have made the requested changes; please review again 🐍🐍🐍
Thanks for making the requested changes!
@berkerpeksag: please review the changes made to this pull request.
type and the argument types of the function, and can be used as decorator |
---|
factories, and as such, be applied to functions through the ``@wrapper`` syntax. |
See :ref:`ctypes-callback-functions` for examples. |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nit: We can drop this extra newline.
This looks pretty good to me, thank you! I will wait for a day or two to let others comment on the PR. Please ping me again if I don't merge this by Friday.
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request
(cherry picked from commit 379e9d6)
Co-authored-by: Andrés Delfino adelfino@gmail.com
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request
(cherry picked from commit 379e9d6)
Co-authored-by: Andrés Delfino adelfino@gmail.com
miss-islington added a commit that referenced this pull request
(cherry picked from commit 379e9d6)
Co-authored-by: Andrés Delfino adelfino@gmail.com
miss-islington added a commit that referenced this pull request
(cherry picked from commit 379e9d6)
Co-authored-by: Andrés Delfino adelfino@gmail.com
CuriousLearner added a commit to CuriousLearner/cpython that referenced this pull request
- master: (2633 commits) bpo-34087: Fix buffer overflow in int(s) and similar functions (pythonGH-8274) bpo-34108: Fix double carriage return in 2to3 on Windows (python#8271) bpo-4260: Document that ctypes.xFUNCTYPE are decorators (pythonGH-7924) bpo-33723: Fix test_time.test_thread_time() (pythonGH-8267) bpo-33967: Remove use of deprecated assertRaisesRegexp() (pythonGH-8261) bpo-34080: Fix a memory leak in the compiler. (pythonGH-8222) Enable GUI testing on Travis Linux builds via Xvfb (pythonGH-7887) bpo-23927: Make getargs.c skipitem() skipping 'w*'. (pythonGH-8192) bpo-33648: Remove PY_WARN_ON_C_LOCALE (pythonGH-7114) bpo-34092, test_logging: increase SMTPHandlerTest timeout (pythonGH-8245) Simplify all in multiprocessing (pythonGH-6856) bpo-34083: Update dict order in Functional HOWTO (pythonGH-8230) Doc: Point to Simple statements section instead of PEP (pythonGH-8238) bpo-29442: Replace optparse with argparse in setup.py (pythonGH-139) bpo-33597: Add What's New for PyGC_Head (pythonGH-8236) Dataclasses: Fix example on 30.6.8, add method should receive a list rather than an integer. (pythonGH-8038) Fix documentation for input and output tutorial (pythonGH-8231) bpo-34009: Expand on platform support changes (pythonGH-8022) Factor-out two substantially identical code blocks. (pythonGH-8219) bpo-34031: fix incorrect usage of self.fail in two tests (pythonGH-8091) ...
CuriousLearner added a commit to CuriousLearner/cpython that referenced this pull request
- master: (1159 commits) bpo-34087: Fix buffer overflow in int(s) and similar functions (pythonGH-8274) bpo-34108: Fix double carriage return in 2to3 on Windows (python#8271) bpo-4260: Document that ctypes.xFUNCTYPE are decorators (pythonGH-7924) bpo-33723: Fix test_time.test_thread_time() (pythonGH-8267) bpo-33967: Remove use of deprecated assertRaisesRegexp() (pythonGH-8261) bpo-34080: Fix a memory leak in the compiler. (pythonGH-8222) Enable GUI testing on Travis Linux builds via Xvfb (pythonGH-7887) bpo-23927: Make getargs.c skipitem() skipping 'w*'. (pythonGH-8192) bpo-33648: Remove PY_WARN_ON_C_LOCALE (pythonGH-7114) bpo-34092, test_logging: increase SMTPHandlerTest timeout (pythonGH-8245) Simplify all in multiprocessing (pythonGH-6856) bpo-34083: Update dict order in Functional HOWTO (pythonGH-8230) Doc: Point to Simple statements section instead of PEP (pythonGH-8238) bpo-29442: Replace optparse with argparse in setup.py (pythonGH-139) bpo-33597: Add What's New for PyGC_Head (pythonGH-8236) Dataclasses: Fix example on 30.6.8, add method should receive a list rather than an integer. (pythonGH-8038) Fix documentation for input and output tutorial (pythonGH-8231) bpo-34009: Expand on platform support changes (pythonGH-8022) Factor-out two substantially identical code blocks. (pythonGH-8219) bpo-34031: fix incorrect usage of self.fail in two tests (pythonGH-8091) ...
CuriousLearner added a commit to CuriousLearner/cpython that referenced this pull request
…ssue-33014
- 'master' of github.com:CuriousLearner/cpython: (722 commits) bpo-34087: Fix buffer overflow in int(s) and similar functions (pythonGH-8274) bpo-34108: Fix double carriage return in 2to3 on Windows (python#8271) bpo-4260: Document that ctypes.xFUNCTYPE are decorators (pythonGH-7924) bpo-33723: Fix test_time.test_thread_time() (pythonGH-8267) bpo-33967: Remove use of deprecated assertRaisesRegexp() (pythonGH-8261) bpo-34080: Fix a memory leak in the compiler. (pythonGH-8222) Enable GUI testing on Travis Linux builds via Xvfb (pythonGH-7887) bpo-23927: Make getargs.c skipitem() skipping 'w*'. (pythonGH-8192) bpo-33648: Remove PY_WARN_ON_C_LOCALE (pythonGH-7114) bpo-34092, test_logging: increase SMTPHandlerTest timeout (pythonGH-8245) Simplify all in multiprocessing (pythonGH-6856) bpo-34083: Update dict order in Functional HOWTO (pythonGH-8230) Doc: Point to Simple statements section instead of PEP (pythonGH-8238) bpo-29442: Replace optparse with argparse in setup.py (pythonGH-139) bpo-33597: Add What's New for PyGC_Head (pythonGH-8236) Dataclasses: Fix example on 30.6.8, add method should receive a list rather than an integer. (pythonGH-8038) Fix documentation for input and output tutorial (pythonGH-8231) bpo-34009: Expand on platform support changes (pythonGH-8022) Factor-out two substantially identical code blocks. (pythonGH-8219) bpo-34031: fix incorrect usage of self.fail in two tests (pythonGH-8091) ...