Skip to content

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

Merged
merged 2 commits into from
Oct 22, 2019
Merged

bpo-38303: Make audioop extension module PEP-384 compatible #16497

merged 2 commits into from
Oct 22, 2019

Conversation

tkieft
Copy link
Contributor

@tkieft tkieft commented Sep 30, 2019

@the-knights-who-say-ni
Copy link

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 Missing

Our records indicate the following people have not signed the CLA:

@tkieft

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
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

PyModule_AddObject(m, "error", AudioopError);
_audioopstate(m)->AudioopError = AudioopError;
}
PyState_AddModule(m, &audioopmodule);
Copy link
Contributor

@eduardo-elizondo eduardo-elizondo Sep 30, 2019

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

if (AudioopError != NULL)
PyDict_SetItemString(d,"error",AudioopError);
PyObject *AudioopError = PyErr_NewException("audioop.error", NULL, NULL);
if (AudioopError != NULL) {
Copy link
Contributor

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

@eduardo-elizondo
Copy link
Contributor

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

Copy link
Contributor

@eduardo-elizondo eduardo-elizondo left a 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.

@tkieft
Copy link
Contributor Author

tkieft commented Sep 30, 2019

Thanks for the review @eduardo-elizondo !

@tkieft
Copy link
Contributor Author

tkieft commented Sep 30, 2019

LOL reading my title again, I was looking at the zlib diff and it was late on a friday smh :|

@tkieft tkieft changed the title bpo-38303: Make audioop extension module zlib-compatible bpo-38303: Make audioop extension module PEP-384 compatible Sep 30, 2019
Copy link
Contributor

@eduardo-elizondo eduardo-elizondo left a comment

Choose a reason for hiding this comment

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

LGTM!

@eduardo-elizondo
Copy link
Contributor

cc: @tiran, @encukou could you take a quick look?

@@ -0,0 +1 @@
Update audioop extension module to conform to PEP-384
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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 :)

} _audioopstate;

#define _audioopstate(o) ((_audioopstate *)PyModule_GetState(o))
#define _audioopstate_global _audioopstate(PyState_FindModule(&audioopmodule))
Copy link
Member

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).

Comment on lines 1906 to 1922
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);
}
Copy link
Member

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.)

Comment on lines 1936 to 1941
PyObject *m;
m = PyState_FindModule(&audioopmodule);
if (m != NULL) {
Py_INCREF(m);
return m;
}
Copy link
Member

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.

@encukou
Copy link
Member

encukou commented Oct 8, 2019

cc @Dormouse759, this might be interesting to you.

@tkieft
Copy link
Contributor Author

tkieft commented Oct 10, 2019

Thanks for the detailed review @encukou - made those changes!

@tkieft
Copy link
Contributor Author

tkieft commented Oct 21, 2019

@encukou - Mind taking another look?

Copy link
Member

@encukou encukou left a 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.

@tkieft
Copy link
Contributor Author

tkieft commented Oct 22, 2019

Don't mind at all! Thanks!

@miss-islington
Copy link
Contributor

Sorry, I can't merge this PR. Reason: Required status check "Azure Pipelines PR" is expected..

@encukou
Copy link
Member

encukou commented Oct 22, 2019

@zooba What's the best way to get Azure Pipelines to run on this PR?
I see some mailing list discussion on this from May; is "close & re-open" is still the way to go? Perhaps long-term enough to document it in the devguide?

@miss-islington
Copy link
Contributor

@tkieft: Status check is done, and it's a success ✅ .

@miss-islington
Copy link
Contributor

Sorry, I can't merge this PR. Reason: Required status check "Azure Pipelines PR" is expected..

@miss-islington
Copy link
Contributor

@tkieft: Status check is done, and it's a success ✅ .

@miss-islington
Copy link
Contributor

Sorry, I can't merge this PR. Reason: Required status check "Azure Pipelines PR" is expected..

@miss-islington
Copy link
Contributor

@tkieft: Status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit f548a3e into python:master Oct 22, 2019
@tkieft tkieft deleted the pep384/audioop branch October 22, 2019 13:10
jacobneiltaylor pushed a commit to jacobneiltaylor/cpython that referenced this pull request Dec 5, 2019
shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request Jan 31, 2020
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.

6 participants