FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-99537: Use Py_SETREF() function in C code by vstinner · Pull Request #99656 · python/cpython · GitHub

/ cpython Public

gh-99537: Use Py_SETREF() function in C code - #99656

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:py_only_setref
Nov 22, 2022
Merged

gh-99537: Use Py_SETREF() function in C code#99656
vstinner merged 1 commit into
python:mainfrom
vstinner:py_only_setref

Conversation

vstinner commented Nov 21, 2022
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

Fix potential race condition in code patterns:

  • Replace "Py_DECREF(var); var = new;" with "Py_SETREF(var, new);"
  • Replace "Py_XDECREF(var); var = new;" with "Py_XSETREF(var, new);"
  • Replace "Py_CLEAR(var); var = new;" with "Py_XSETREF(var, new);"

Other changes:

  • Replace "old = var; var = new; Py_DECREF(var)" with "Py_SETREF(var, new);"
  • Replace "old = var; var = new; Py_XDECREF(var)" with "Py_XSETREF(var, new);"
  • And remove the "old" variable.

Copy link
Copy Markdown
Contributor

LGTM (for the sqlite3 changes)

Fix potential race condition in code patterns:

* Replace "Py_DECREF(var); var = new;" with "Py_SETREF(var, new);"
* Replace "Py_XDECREF(var); var = new;" with "Py_XSETREF(var, new);"
* Replace "Py_CLEAR(var); var = new;" with "Py_XSETREF(var, new);"

Other changes:

* Replace "old = var; var = new; Py_DECREF(var)"
  with "Py_SETREF(var, new);"
* Replace "old = var; var = new; Py_XDECREF(var)"
  with "Py_XSETREF(var, new);"
* And remove the "old" variable.

vstinner commented Nov 22, 2022
edited
Loading

Copy link
Copy Markdown
Member Author

I rebased and modified my PR to add a second change to Modules/_datetimemodule.c.

vstinner merged commit 7e3f09c into python:main Nov 22, 2022
vstinner deleted the py_only_setref branch November 22, 2022 13:34
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
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.

3 participants


Back | FazBrowse Home | New Git URL