Skip to content

Remove comment from pystate created in 2003 #123259

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
Aug 24, 2024

Conversation

tonybaloney
Copy link
Contributor

This is a very minor change, but in pystate there's a check that thread state shouldn't be null when releasing the GIL.

This is a very useful check. If someone accidentally calls release GIL and didn't acquire the GIL from a native thread in an embedded Python scenario, they get this helpful fatal error message because there is no thread state.

I noticed there is a TODO above this check speculating that it isn't required dating back to 2003.

It is required because it avoids a crash and null lookup.

This PR removes the comment.

@gmarkall
Copy link

If this check needs to be kept, does this mean that the following assert(holds_gil(tstate)); is redundant and could be removed too?

@tonybaloney
Copy link
Contributor Author

If this check needs to be kept, does this mean that the following assert(holds_gil(tstate)); is redundant and could be removed too?

That code is unreachable, so yes

@hauntsaninja hauntsaninja enabled auto-merge (squash) August 24, 2024 20:36
@hauntsaninja hauntsaninja merged commit 86f06cb into python:main Aug 24, 2024
38 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants