diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-05-23 09:28:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-23 09:28:04 (GMT) |
commit | e43fbbd92884ad167cdaea296526c671f593b234 (patch) | |
tree | 6b8034d0237027a817eeac9c9c8696af06348c9b /Include | |
parent | 905d419cac0e2617ee07c8a478e132793878a875 (diff) | |
download | cpython-e43fbbd92884ad167cdaea296526c671f593b234.zip cpython-e43fbbd92884ad167cdaea296526c671f593b234.tar.gz cpython-e43fbbd92884ad167cdaea296526c671f593b234.tar.bz2 |
[3.12] GH-101291: Avoid using macros with casts in low-level long API. (GH-104742) (#104759)
(cherry picked from commit e295d8605699ad3d8ec46c8d55a5e47da05b20c6)
Co-authored-by: Mark Shannon <mark@hotpy.org>
Diffstat (limited to 'Include')
-rw-r--r-- | Include/cpython/longintrepr.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Include/cpython/longintrepr.h b/Include/cpython/longintrepr.h index 0f56993..692c69b 100644 --- a/Include/cpython/longintrepr.h +++ b/Include/cpython/longintrepr.h @@ -104,9 +104,10 @@ _PyLong_FromDigits(int negative, Py_ssize_t digit_count, digit *digits); #define _PyLong_SIGN_MASK 3 #define _PyLong_NON_SIZE_BITS 3 + static inline int _PyLong_IsCompact(const PyLongObject* op) { - assert(PyLong_Check(op)); + assert(PyType_HasFeature((op)->ob_base.ob_type, Py_TPFLAGS_LONG_SUBCLASS)); return op->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS); } @@ -115,7 +116,7 @@ _PyLong_IsCompact(const PyLongObject* op) { static inline Py_ssize_t _PyLong_CompactValue(const PyLongObject *op) { - assert(PyLong_Check(op)); + assert(PyType_HasFeature((op)->ob_base.ob_type, Py_TPFLAGS_LONG_SUBCLASS)); assert(PyUnstable_Long_IsCompact(op)); Py_ssize_t sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK); return sign * (Py_ssize_t)op->long_value.ob_digit[0]; |