Skip to content

bpo-1635741: Port audioop extension module to multiphase initialization(PEP 489) - #18608

Merged
vstinner merged 7 commits into
python:masterfrom
shihai1991:bpo_1635741_audioop
Mar 11, 2020
Merged

bpo-1635741: Port audioop extension module to multiphase initialization(PEP 489)#18608
vstinner merged 7 commits into
python:masterfrom
shihai1991:bpo_1635741_audioop

Conversation

@shihai1991

@shihai1991shihai1991 commented Feb 22, 2020

Copy link
Copy Markdown
Member

@codecov

codecovBot commented Feb 22, 2020

Copy link
Copy Markdown

Codecov Report

Merging #18608 into master will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@ Coverage Diff @@## master #18608 +/- ##
==========================================
+ Coverage 82.11% 82.13% +0.01% 
==========================================
Files 1956 1955 -1 Lines 589425 584605 -4820 Branches 44458 44484 +26 ==========================================
- Hits 484018 480164 -3854 + Misses 95752 94793 -959 + Partials 9655 9648 -7 
Impacted FilesCoverage Δ
Lib/distutils/tests/test_bdist_rpm.py30.00% <0.00%> (-65.00%)⬇️
Lib/distutils/command/bdist_rpm.py7.63% <0.00%> (-56.88%)⬇️
Modules/_decimal/libmpdec/umodarith.h80.76% <0.00%> (-19.24%)⬇️
Lib/test/test_urllib2net.py76.92% <0.00%> (-13.85%)⬇️
Lib/test/test_smtpnet.py78.57% <0.00%> (-7.15%)⬇️
Lib/ftplib.py63.85% <0.00%> (-6.06%)⬇️
Lib/test/test_ftplib.py87.11% <0.00%> (-4.72%)⬇️
Tools/scripts/db2pickle.py17.82% <0.00%> (-3.97%)⬇️
Tools/scripts/pickle2db.py16.98% <0.00%> (-3.78%)⬇️
Lib/test/test_socket.py71.94% <0.00%> (-3.77%)⬇️
... and 352 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c56f8f...5364b74. Read the comment docs.

@shihai1991

Copy link
Copy Markdown
MemberAuthor

Looks there have an potential bug, because running test_audioop test case, the error name not belong to audioop: binascii.Error: Input sample should be longer

@shihai1991shihai1991 changed the title bpo-1635741: Port audioop extension module to multiphase initialization(PEP 489)[WIP] bpo-1635741: Port audioop extension module to multiphase initialization(PEP 489)Feb 23, 2020
@encukou

Copy link
Copy Markdown
Member

I don't have a Windows machine to test this on.
But, I see that the struct name and the macro to get it are both called _audioopstate! I missed that in my earlier review :(

Could you first turn the macro into an inline function, and rename the type (to something like audioop_state)?

@shihai1991

Copy link
Copy Markdown
MemberAuthor

I don't have a Windows machine to test this on.
But, I see that the struct name and the macro to get it are both called _audioopstate! I missed that in my earlier review :(

Could you first turn the macro into an inline function, and rename the type (to something like audioop_state)?

of course, let me try it now ;)

@shihai1991

Copy link
Copy Markdown
MemberAuthor

petr, it's failed again, so I try to find a win env to debug~

Comment threadModules/audioop.c
audioop_traverse(PyObject *m, visitproc visit, void *arg)
{
audioop_state *state = (audioop_state *)PyModule_GetState(m);
if (state) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it really possible that state can be NULL when this function is called?

Comment threadModules/audioop.c
audioop_clear(PyObject *m)
{
audioop_state *state = (audioop_state *)PyModule_GetState(m);
if (state) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it really possible that state can be NULL when this function is called?

module_clear() doesn't touch module->md_state value. Only module_dealloc() calls PyMem_FREE(m->md_state). But audioop_clear() must not be called on a deallocated module object.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would prefer to see this question answered before approving the PR.

@encukouencukouMar 1, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Is it worth us to change this logic as victor said?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I created https://bugs.python.org/issue39824 to propose to change the Python behavior, so modules would not have to handle md_state=NULL anymore.

Comment threadModules/audioop.c Outdated
Co-Authored-By: Victor Stinner <vstinner@python.org>
@shihai1991shihai1991 changed the title [WIP] bpo-1635741: Port audioop extension module to multiphase initialization(PEP 489)bpo-1635741: Port audioop extension module to multiphase initialization(PEP 489)Mar 1, 2020
@shihai1991

Copy link
Copy Markdown
MemberAuthor

Oh, gate have passed, thanks, victor.

@vstinner
vstinner merged commit 41fbf86 into python:masterMar 11, 2020
Sign up for freeto 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.

5 participants

@shihai1991@encukou@vstinner@the-knights-who-say-ni@bedevere-bot