-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-38303: Make audioop extension module PEP-384 compatible #16497
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
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
Modules/audioop.c
Outdated
PyModule_AddObject(m, "error", AudioopError); | ||
_audioopstate(m)->AudioopError = AudioopError; | ||
} | ||
PyState_AddModule(m, &audioopmodule); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this line here. This is being discussed in PR16101 and very likely the documentation will change to indicate that it's not needed
Modules/audioop.c
Outdated
if (AudioopError != NULL) | ||
PyDict_SetItemString(d,"error",AudioopError); | ||
PyObject *AudioopError = PyErr_NewException("audioop.error", NULL, NULL); | ||
if (AudioopError != NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's follow what most extensions do and return NULL
if this fails. An example of this is: _localemodule
Take a look at the following URL and add a NEWS file about your change: https://devguide.python.org/committing/#what-s-new-and-news-entries Also, change your title to: "Update audioop.c to PEP-384" Like: PR15975 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of changes.
Thanks for the review @eduardo-elizondo ! |
LOL reading my title again, I was looking at the zlib diff and it was late on a friday smh :| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -0,0 +1 @@ | |||
Update audioop extension module to conform to PEP-384 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update audioop extension module to conform to PEP-384 | |
Update audioop extension module to use the stable ABI (PEP-384) |
This is a bit of a pet peeve of mine: PEP numbers are only understandable to people who work with that particular PEP. The What's New document deserves better :)
Modules/audioop.c
Outdated
} _audioopstate; | ||
|
||
#define _audioopstate(o) ((_audioopstate *)PyModule_GetState(o)) | ||
#define _audioopstate_global _audioopstate(PyState_FindModule(&audioopmodule)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_audioopstate_global
should be unnecessary. The module is readily available at all call sites (except for two helper functions whose callers have the module ready).
Using _audioopstate(module)
instead should be both faster and more future-proof (see PEP 489, multi-phase init).
Modules/audioop.c
Outdated
static int | ||
audioop_traverse(PyObject *m, visitproc visit, void *arg) { | ||
Py_VISIT(_audioopstate(m)->AudioopError); | ||
return 0; | ||
} | ||
static int | ||
audioop_clear(PyObject *m) { | ||
Py_CLEAR(_audioopstate(m)->AudioopError); | ||
return 0; | ||
} | ||
static void | ||
audioop_free(void *m) { | ||
audioop_clear((PyObject *)m); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all three functions, the module state may be NULL. Please check the possibility.
(AudioopError
may be NULL as well, but the Py_VISIT
/Py_CLEAR
macros deal with that.)
Modules/audioop.c
Outdated
PyObject *m; | ||
m = PyState_FindModule(&audioopmodule); | ||
if (m != NULL) { | ||
Py_INCREF(m); | ||
return m; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unnecessary; the import mechanism should ensure only one copy of the extension module is imported.
cc @Dormouse759, this might be interesting to you. |
Thanks for the detailed review @encukou - made those changes! |
@encukou - Mind taking another look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tkieft, I hope you don't mind your name in the ACKs. If so, this is good to merge.
Don't mind at all! Thanks! |
Sorry, I can't merge this PR. Reason: |
@zooba What's the best way to get Azure Pipelines to run on this PR? |
@tkieft: Status check is done, and it's a success ✅ . |
Sorry, I can't merge this PR. Reason: |
@tkieft: Status check is done, and it's a success ✅ . |
Sorry, I can't merge this PR. Reason: |
@tkieft: Status check is done, and it's a success ✅ . |
https://bugs.python.org/issue38303
Automerge-Triggered-By: @encukou