mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
longobject.c: add an assertion to ensure that MEDIUM_VALUE() is only called on
small integers (0 or 1 digit)
This commit is contained in:
parent
8aed6f1c7d
commit
08a80b11ad
1 changed files with 2 additions and 1 deletions
|
@ -17,7 +17,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* convert a PyLong of size 1, 0 or -1 to an sdigit */
|
/* convert a PyLong of size 1, 0 or -1 to an sdigit */
|
||||||
#define MEDIUM_VALUE(x) (Py_SIZE(x) < 0 ? -(sdigit)(x)->ob_digit[0] : \
|
#define MEDIUM_VALUE(x) (assert(-1 <= Py_SIZE(x) && Py_SIZE(x) <= 1), \
|
||||||
|
Py_SIZE(x) < 0 ? -(sdigit)(x)->ob_digit[0] : \
|
||||||
(Py_SIZE(x) == 0 ? (sdigit)0 : \
|
(Py_SIZE(x) == 0 ? (sdigit)0 : \
|
||||||
(sdigit)(x)->ob_digit[0]))
|
(sdigit)(x)->ob_digit[0]))
|
||||||
#define ABS(x) ((x) < 0 ? -(x) : (x))
|
#define ABS(x) ((x) < 0 ? -(x) : (x))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue