https://github.com/python/cpython/commit/b359f66c4c315ca14b2a075ee136145ba6610760
commit: b359f66c4c315ca14b2a075ee136145ba6610760
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2024-07-28T09:59:07+02:00
summary:

gh-120593: Make _PyLong_CompactValue() parameter const again (#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.

files:
M Include/cpython/longintrepr.h

diff --git a/Include/cpython/longintrepr.h b/Include/cpython/longintrepr.h
index d841c043f37fc4..c60ccc463653f9 100644
--- a/Include/cpython/longintrepr.h
+++ b/Include/cpython/longintrepr.h
@@ -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];

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to