Skip to content

bpo-15088 : Remove PyGen_NeedsFinalizing() #15702

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 10 commits into from
Sep 6, 2019

Conversation

nanjekyejoannah
Copy link
Contributor

@nanjekyejoannah nanjekyejoannah commented Sep 5, 2019

I made PyGen_NeedsFinalizing() internal instead of deleting the logic all together much as the function is not called anywhere in the codebase. Should I have done the later? @vstinner @pitrou

Edit: We decided to remove it all together.

https://bugs.python.org/issue15088

@pitrou
Copy link
Member

pitrou commented Sep 5, 2019

Well, it makes no sense to make it internal if it's not used internally. I see two possible resolutions:

  • If it's used by third-party code, leave it as-is (or deprecate it if the semantics aren't useful)
  • If it's not used by third-party code, remove it (or deprecate it with a removal notice for a later release)

@nanjekyejoannah
Copy link
Contributor Author

Well, it makes no sense to make it internal if it's not used internally. I see two possible resolutions:

* If it's used by third-party code, leave it as-is (or deprecate it if the semantics aren't useful)

* If it's not used by third-party code, remove it (or deprecate it with a removal notice for a later release)

My searches show references to this function in CPython cloned repositories. From your views, I think it is better to deprecate it with a removal notice for a later release.

@nanjekyejoannah nanjekyejoannah changed the title bpo-15088 : Remove PyGen_NeedsFinalizing() bpo-15088 : Deprecate PyGen_NeedsFinalizing() Sep 5, 2019
@nanjekyejoannah
Copy link
Contributor Author

I have deprecated the Function instead and will be removed in the next release.

@vstinner
Copy link
Member

vstinner commented Sep 5, 2019

IMHO it's not worth it to have a deprecation period, since the function is not documented, not tested and I cannot find any project using it. See my rationale:
https://bugs.python.org/issue15088#msg351207

This function really looks like an internal function which leaked to the C API by mistake.

I propose to remove it immediately. What do you think @pitrou?

@pitrou wrote:

If it's not used by third-party code, remove it (or deprecate it with a removal notice for a later release)

Since I understand that he is fine with removing it.

We just have to document clearly its removal at: https://docs.python.org/dev/whatsnew/3.9.html#build-and-c-api-changes

@nanjekyejoannah nanjekyejoannah changed the title bpo-15088 : Deprecate PyGen_NeedsFinalizing() bpo-15088 : Remove PyGen_NeedsFinalizing() Sep 5, 2019
@nanjekyejoannah
Copy link
Contributor Author

Appveyor is giving me a red with a result I don't understand to resolve i.e "Tests result: ENV CHANGED" @vstinner ideas?

@aeros aeros added the type-feature A feature request or enhancement label Sep 5, 2019
@aeros
Copy link
Contributor

aeros commented Sep 5, 2019

IMHO it's not worth it to have a deprecation period, since the function is not documented, not tested and I cannot find any project using it.

If it's not being used anywhere else, I think it's safe to remove it. Having a deprecation period adds additional maintenance. From my understanding, our general practice has been that anything which is not documented is not guaranteed to be part of the public API.

@pitrou
Copy link
Member

pitrou commented Sep 5, 2019

I propose to remove it immediately. What do you think @pitrou?

No opposition from me, though I generally find it nicer to at least leave it deprecated for one version (you never know what non-public code may do).

Copy link
Contributor

@aeros aeros left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @nanjekyejoannah.

From what I can tell, AppVeyor seems to be failing with ENV_CHANGED due to
1 test altered the execution environment: test_asyncio
Upon further inspection, it looks like env changed occurred only on line 1094 of the build log:

[00:09:54] 0:03:38 load avg: 5.63 [224/419/1] test_asyncio failed (env changed) (1 min 18 sec) -- running: test_multiprocessing_spawn (1 min 48 sec)

I'm not certain as to the cause though.

Copy link
Contributor

@aeros aeros left a comment

Choose a reason for hiding this comment

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

I would recommend some minor modifications to the Misc/NEWS and What's New entries.

Current:

The C function ``PyGen_NeedsFinalizing`` has been removed. It was not
documented, tested or even used anywhere in the code base after
PEP 442 implementation made it useless.
(Patch by Joannah Nanjekye)

Suggested:

The C function ``PyGen_NeedsFinalizing`` has been removed. It was not
documented, tested or used anywhere within CPython after the implementation
of :pep:`442`. Patch by Joannah Nanjekye.

I adjusted the phrasing, made the entry more succinct, and made a few formatting changes. Most notably, I condensed the lines so they could fit the maximum number of words on each line (within the 80 char width limit of reST) and added Sphinx markup for PEP 442 to provide an external link for readers.

@vstinner
Copy link
Member

vstinner commented Sep 6, 2019

No opposition from me, though I generally find it nicer to at least leave it deprecated for one version (you never know what non-public code may do).

My worry is that nobody pays attention to compiler warnings.

I'm not sure that mentioning the deprecation in the documentation would be enough to notify potential users that it's deprecated.

Outside Python internals, I don't see why anyone would need this function?

PyGenObject structure is currently exposed, so it's possible to copy/paste this function in a closed source project if needed. It's short:

int 7(PyGenObject *gen)
{
    PyFrameObject *f = gen->gi_frame;
    if (f == NULL || f->f_stacktop == NULL) return 0;
    if (f->f_iblock > 0) return 1;
    return 0;
}

If we remove the function at the beginning of the 3.9 dev cycle, I also hope that enough users will test Python 3.8 beta versions, to check if they still compile without PyGen_NeedsFinalizing :-)

@vstinner
Copy link
Member

vstinner commented Sep 6, 2019

@nanjekyejoannah:

Appveyor is giving me a red with a result I don't understand to resolve i.e "Tests result: ENV CHANGED" @vstinner ideas?

It's a random falure. If you make a change to your PR, a new CI job will be run and it will be fine (I hope).

I reported this asyncio bug more than one year ago. I even wrote a fix:
https://bugs.python.org/issue34037

But my fix has been reverted:
#13802

Does anyone want to make changes requested by @1st1?

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM.

@vstinner
Copy link
Member

vstinner commented Sep 6, 2019

@nanjekyejoannah: I let you modify the documentation according to @aeros167 suggestion, and then I plan to merge your change.

@aeros
Copy link
Contributor

aeros commented Sep 6, 2019

@vstinner

Does anyone want to make changes requested by @1st1?

Although I am not the most experienced with the internals of asyncio, I would be willing to try to help with this.

@nanjekyejoannah
Copy link
Contributor Author

Thanks, @aeros167 for suggestions I have made the requested changes. @vstinner PTAL.

@vstinner vstinner merged commit 74b662c into python:master Sep 6, 2019
@vstinner
Copy link
Member

vstinner commented Sep 6, 2019

I merged your PR @nanjekyejoannah, thanks. If anyone uses it, please complain before Python 3.9.0 release :-)

@nanjekyejoannah nanjekyejoannah deleted the issue15088 branch September 7, 2019 11:49
lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
Remove PyGen_NeedsFinalizing(): it was not
documented, tested or used anywhere within CPython after
the implementation of PEP 442.
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
Remove PyGen_NeedsFinalizing(): it was not
documented, tested or used anywhere within CPython after
the implementation of PEP 442.
websurfer5 pushed a commit to websurfer5/cpython that referenced this pull request Jul 20, 2020
Remove PyGen_NeedsFinalizing(): it was not
documented, tested or used anywhere within CPython after
the implementation of PEP 442.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants