mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
Issue #21490: Add new C macros: Py_ABS() and Py_STRINGIFY()
Keep _Py_STRINGIZE() in PC/pyconfig.h to not introduce a dependency between pyconfig.h and pymacros.h.
This commit is contained in:
parent
79b49ab553
commit
45e8e2f218
7 changed files with 60 additions and 59 deletions
|
@ -13,8 +13,6 @@
|
|||
#include "code.h"
|
||||
#include "marshal.h"
|
||||
|
||||
#define ABS(x) ((x) < 0 ? -(x) : (x))
|
||||
|
||||
/* High water mark to determine when the marshalled object is dangerously deep
|
||||
* and risks coring the interpreter. When the object stack gets this deep,
|
||||
* raise an exception instead of continuing.
|
||||
|
@ -192,7 +190,7 @@ w_PyLong(const PyLongObject *ob, char flag, WFILE *p)
|
|||
}
|
||||
|
||||
/* set l to number of base PyLong_MARSHAL_BASE digits */
|
||||
n = ABS(Py_SIZE(ob));
|
||||
n = Py_ABS(Py_SIZE(ob));
|
||||
l = (n-1) * PyLong_MARSHAL_RATIO;
|
||||
d = ob->ob_digit[n-1];
|
||||
assert(d != 0); /* a PyLong is always normalized */
|
||||
|
@ -727,8 +725,8 @@ r_PyLong(RFILE *p)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
size = 1 + (ABS(n) - 1) / PyLong_MARSHAL_RATIO;
|
||||
shorts_in_top_digit = 1 + (ABS(n) - 1) % PyLong_MARSHAL_RATIO;
|
||||
size = 1 + (Py_ABS(n) - 1) / PyLong_MARSHAL_RATIO;
|
||||
shorts_in_top_digit = 1 + (Py_ABS(n) - 1) % PyLong_MARSHAL_RATIO;
|
||||
ob = _PyLong_New(size);
|
||||
if (ob == NULL)
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue