bpo-38733: PyErr_Occurred() caller must hold the GIL by vstinner · Pull Request #17080 · python/cpython (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation3 Commits1 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

vstinner

bpo-3605, bpo-38733: Optimize _PyErr_Occurred(): remove "tstate ==
NULL" test.

Py_FatalError() no longer calls PyErr_Occurred() if called without
holding the GIL. So PyErr_Occurred() no longer has to support
tstate==NULL case.

_Py_CheckFunctionResult(): use directly _PyErr_Occurred() to avoid
explicit "!= NULL" test.

https://bugs.python.org/issue38733

@vstinner

bpo-3605, bpo-38733: Optimize _PyErr_Occurred(): remove "tstate == NULL" test.

Py_FatalError() no longer calls PyErr_Occurred() if called without holding the GIL. So PyErr_Occurred() no longer has to support tstate==NULL case.

_Py_CheckFunctionResult(): use directly _PyErr_Occurred() to avoid explicit "!= NULL" test.

@vstinner vstinner changed the titlebpo-38733: The GIL must be hold to call PyErr_Occurred() bpo-38733: PyErr_Occurred() caller must hold the GIL

Nov 7, 2019

@vstinner

@pablogsal, @serhiy-storchaka, @methane, @pitrou: Would you mind to review this change?

I didn't add a NEWS entry since I consider that PyErr_Occurred() caller always had to hold the GIL. Do you consider that it should be documented?

pitrou

Choose a reason for hiding this comment

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

+1

serhiy-storchaka

@vstinner

@pitrou, @serhiy-storchaka: Oh, thanks for your quick approval.

I really wasn't sure about this change on the critical function PyErr_Occurred(). Well, if this change breaks too many projects, we still have time to revert is before 3.9 final and plan a better upgrade path ;-)

jacobneiltaylor pushed a commit to jacobneiltaylor/cpython that referenced this pull request

Dec 5, 2019

@vstinner

bpo-3605, bpo-38733: Optimize _PyErr_Occurred(): remove "tstate == NULL" test.

Py_FatalError() no longer calls PyErr_Occurred() if called without holding the GIL. So PyErr_Occurred() no longer has to support tstate==NULL case.

_Py_CheckFunctionResult(): use directly _PyErr_Occurred() to avoid explicit "!= NULL" test.

shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request

Jan 31, 2020

@vstinner @shihai1991

bpo-3605, bpo-38733: Optimize _PyErr_Occurred(): remove "tstate == NULL" test.

Py_FatalError() no longer calls PyErr_Occurred() if called without holding the GIL. So PyErr_Occurred() no longer has to support tstate==NULL case.

_Py_CheckFunctionResult(): use directly _PyErr_Occurred() to avoid explicit "!= NULL" test.