Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix C++ compatibility in _PyCell_GetStackRef
  • Loading branch information
yoney committed Feb 4, 2026
commit 39d126d17a48f14de9dcc6fc80a3a13f50ed87b3
2 changes: 1 addition & 1 deletion Include/internal/pycore_cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ _PyCell_GetStackRef(PyCellObject *cell)
{
PyObject *value;
#ifdef Py_GIL_DISABLED
value = _Py_atomic_load_ptr(&cell->ob_ref);
value = (PyObject *)_Py_atomic_load_ptr(&cell->ob_ref);

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.

Up to you, but I believe we've used _Py_STATIC_CAST for things like this in the past. That will expand to static_cast<type>(expr) in C++, and then the usual (type)(expr) in C.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Most other headers use _PyObject_CAST so I think we should use that instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I grepped for _Py_STATIC_CAST and _PyObject_CAST. There were more usages of _PyObject_CAST, so I changed it to that.

if (value == NULL) {
return PyStackRef_NULL;
}
Expand Down
Loading