Skip to content

Commit

Permalink
[3.13] gh-123091: Use _Py_IsImmortalLoose() (#123511) (#123600)
Browse files Browse the repository at this point in the history
gh-123091: Use _Py_IsImmortalLoose() (#123511)

Use _Py_IsImmortalLoose() in bytesobject.c, typeobject.c
and ceval.c.

(cherry picked from commit f1a0d96)
  • Loading branch information
vstinner authored Sep 2, 2024
1 parent b76a4a5 commit 10735bf
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Objects/bytesobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Py_LOCAL_INLINE(Py_ssize_t) _PyBytesWriter_GetSize(_PyBytesWriter *writer,
static inline PyObject* bytes_get_empty(void)
{
PyObject *empty = &EMPTY->ob_base.ob_base;
assert(_Py_IsImmortal(empty));
assert(_Py_IsImmortalLoose(empty));
return empty;
}

Expand Down Expand Up @@ -119,7 +119,7 @@ PyBytes_FromStringAndSize(const char *str, Py_ssize_t size)
}
if (size == 1 && str != NULL) {
op = CHARACTER(*str & 255);
assert(_Py_IsImmortal(op));
assert(_Py_IsImmortalLoose(op));
return (PyObject *)op;
}
if (size == 0) {
Expand Down Expand Up @@ -155,7 +155,7 @@ PyBytes_FromString(const char *str)
}
else if (size == 1) {
op = CHARACTER(*str & 255);
assert(_Py_IsImmortal(op));
assert(_Py_IsImmortalLoose(op));
return (PyObject *)op;
}

Expand Down
8 changes: 4 additions & 4 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ set_tp_bases(PyTypeObject *self, PyObject *bases, int initial)
assert(PyTuple_GET_SIZE(bases) == 1);
assert(PyTuple_GET_ITEM(bases, 0) == (PyObject *)self->tp_base);
assert(self->tp_base->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN);
assert(_Py_IsImmortal(self->tp_base));
assert(_Py_IsImmortalLoose(self->tp_base));
}
_Py_SetImmortal(bases);
}
Expand All @@ -469,7 +469,7 @@ clear_tp_bases(PyTypeObject *self, int final)
Py_CLEAR(self->tp_bases);
}
else {
assert(_Py_IsImmortal(self->tp_bases));
assert(_Py_IsImmortalLoose(self->tp_bases));
_Py_ClearImmortal(self->tp_bases);
}
}
Expand Down Expand Up @@ -534,7 +534,7 @@ clear_tp_mro(PyTypeObject *self, int final)
Py_CLEAR(self->tp_mro);
}
else {
assert(_Py_IsImmortal(self->tp_mro));
assert(_Py_IsImmortalLoose(self->tp_mro));
_Py_ClearImmortal(self->tp_mro);
}
}
Expand Down Expand Up @@ -5657,7 +5657,7 @@ fini_static_type(PyInterpreterState *interp, PyTypeObject *type,
int isbuiltin, int final)
{
assert(type->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN);
assert(_Py_IsImmortal((PyObject *)type));
assert(_Py_IsImmortalLoose((PyObject *)type));

type_dealloc_common(type);

Expand Down
4 changes: 2 additions & 2 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ dummy_func(
EXIT_IF(!PyLong_CheckExact(value));
STAT_INC(TO_BOOL, hit);
if (_PyLong_IsZero((PyLongObject *)value)) {
assert(_Py_IsImmortal(value));
assert(_Py_IsImmortalLoose(value));
res = Py_False;
}
else {
Expand All @@ -389,7 +389,7 @@ dummy_func(
EXIT_IF(!PyUnicode_CheckExact(value));
STAT_INC(TO_BOOL, hit);
if (value == &_Py_STR(empty)) {
assert(_Py_IsImmortal(value));
assert(_Py_IsImmortalLoose(value));
res = Py_False;
}
else {
Expand Down
4 changes: 2 additions & 2 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 10735bf

Please sign in to comment.