Skip to content

Commit

Permalink
pythongh-120593: Make _PyLong_CompactValue() parameter const again (p…
Browse files Browse the repository at this point in the history
…ython#122367)

Change _PyLong_IsCompact() and _PyLong_CompactValue() parameter type
from 'PyObject*' to 'const PyObject*'. Avoid the Py_TYPE() macro
which does not support const parameter.
  • Loading branch information
vstinner authored Jul 28, 2024
1 parent aa449cf commit b359f66
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Include/cpython/longintrepr.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,18 @@ PyAPI_FUNC(PyLongObject*) _PyLong_FromDigits(


static inline int
_PyLong_IsCompact(PyLongObject* op) {
assert(PyType_HasFeature(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS));
_PyLong_IsCompact(const PyLongObject* op) {
assert(PyType_HasFeature(op->ob_base.ob_type, Py_TPFLAGS_LONG_SUBCLASS));
return op->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS);
}

#define PyUnstable_Long_IsCompact _PyLong_IsCompact

static inline Py_ssize_t
_PyLong_CompactValue(PyLongObject *op)
_PyLong_CompactValue(const PyLongObject *op)
{
Py_ssize_t sign;
assert(PyType_HasFeature(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS));
assert(PyType_HasFeature(op->ob_base.ob_type, Py_TPFLAGS_LONG_SUBCLASS));
assert(PyUnstable_Long_IsCompact(op));
sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK);
return sign * (Py_ssize_t)op->long_value.ob_digit[0];
Expand Down

0 comments on commit b359f66

Please sign in to comment.