Use _PyLong_GetZero() and _PyLong_GetOne() in Modules/ directory.
_cursesmodule.c and zoneinfo.c are now built with
Py_BUILD_CORE_MODULE macro defined.
#_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator
#_pickle _pickle.c # pickle accelerator
#_datetime _datetimemodule.c # datetime accelerator
-#_zoneinfo _zoneinfo.c # zoneinfo accelerator
+#_zoneinfo _zoneinfo.c -DPy_BUILD_CORE_MODULE # zoneinfo accelerator
#_bisect _bisectmodule.c # Bisection algorithms
#_heapq _heapqmodule.c -DPy_BUILD_CORE_MODULE # Heap queue algorithm
#_asyncio _asynciomodule.c # Fast asyncio Future
# provided by the ncurses library. e.g. on Linux, link with -lncurses
# instead of -lcurses).
-#_curses _cursesmodule.c -lcurses -ltermcap
+#_curses _cursesmodule.c -lcurses -ltermcap -DPy_BUILD_CORE_MODULE
# Wrapper for the panel library that's part of ncurses and SYSV curses.
#_curses_panel _curses_panel.c -lpanel -lncurses
#include "Python.h"
+#include "pycore_long.h" // _PyLong_GetZero()
#include "structmember.h" // PyMemberDef
#ifdef STDC_HEADERS
if (oldval == NULL) {
if (PyErr_Occurred())
goto done;
- if (_PyDict_SetItem_KnownHash(mapping, key, _PyLong_One, hash) < 0)
+ if (_PyDict_SetItem_KnownHash(mapping, key, _PyLong_GetOne(), hash) < 0)
goto done;
} else {
- newval = PyNumber_Add(oldval, _PyLong_One);
+ newval = PyNumber_Add(oldval, _PyLong_GetOne());
if (newval == NULL)
goto done;
if (_PyDict_SetItem_KnownHash(mapping, key, newval, hash) < 0)
if (bound_get == NULL)
goto done;
+ PyObject *zero = _PyLong_GetZero(); // borrowed reference
+ PyObject *one = _PyLong_GetOne(); // borrowed reference
while (1) {
key = PyIter_Next(it);
if (key == NULL)
break;
- oldval = PyObject_CallFunctionObjArgs(bound_get, key, _PyLong_Zero, NULL);
+ oldval = PyObject_CallFunctionObjArgs(bound_get, key, zero, NULL);
if (oldval == NULL)
break;
- newval = PyNumber_Add(oldval, _PyLong_One);
+ newval = PyNumber_Add(oldval, one);
Py_DECREF(oldval);
if (newval == NULL)
break;
#endif
#include "ctypes.h"
+#include "pycore_long.h" // _PyLong_GetZero()
+
PyObject *PyExc_ArgError = NULL;
/* This dict maps ctypes types to POINTER types */
case PARAMFLAG_FIN | PARAMFLAG_FLCID:
/* ['in', 'lcid'] parameter. Always taken from defval,
if given, else the integer 0. */
- if (defval == NULL)
- defval = _PyLong_Zero;
+ if (defval == NULL) {
+ defval = _PyLong_GetZero();
+ }
Py_INCREF(defval);
PyTuple_SET_ITEM(callargs, i, defval);
break;
#define PY_SSIZE_T_CLEAN
#include "Python.h"
+#include "pycore_long.h" // _PyLong_GetZero()
#ifdef __hpux
_curses.window.box
[
- verch: object(c_default="_PyLong_Zero") = 0
+ verch: object(c_default="_PyLong_GetZero()") = 0
Left and right side.
- horch: object(c_default="_PyLong_Zero") = 0
+ horch: object(c_default="_PyLong_GetZero()") = 0
Top and bottom side.
]
/
static PyObject *
_curses_window_box_impl(PyCursesWindowObject *self, int group_right_1,
PyObject *verch, PyObject *horch)
-/*[clinic end generated code: output=f3fcb038bb287192 input=465a121741c1efdf]*/
+/*[clinic end generated code: output=f3fcb038bb287192 input=f00435f9c8c98f60]*/
{
chtype ch1 = 0, ch2 = 0;
if (group_right_1) {
#define _PY_DATETIME_IMPL
#include "Python.h"
+#include "pycore_long.h" // _PyLong_GetOne()
#include "pycore_object.h" // _PyObject_Init()
#include "datetime.h"
#include "structmember.h" // PyMemberDef
goto Done
if (us) {
- y = accum("microseconds", x, us, _PyLong_One, &leftover_us);
+ y = accum("microseconds", x, us, _PyLong_GetOne(), &leftover_us);
CLEANUP;
}
if (ms) {
* is odd. Note that x is odd when it's last bit is 1. The
* code below uses bitwise and operation to check the last
* bit. */
- temp = PyNumber_And(x, _PyLong_One); /* temp <- x & 1 */
+ temp = PyNumber_And(x, _PyLong_GetOne()); /* temp <- x & 1 */
if (temp == NULL) {
Py_DECREF(x);
goto Done;
#include "Python.h"
+#include "pycore_long.h" // _PyLong_GetZero()
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_tuple.h" // _PyTuple_ITEMS()
#include "structmember.h" // PyMemberDef
return NULL;
}
- answer = PyObject_RichCompare(res, _PyLong_Zero, op);
+ answer = PyObject_RichCompare(res, _PyLong_GetZero(), op);
Py_DECREF(res);
return answer;
}
#define PY_SSIZE_T_CLEAN
#include "Python.h"
+#include "pycore_long.h" // _PyLong_GetOne()
#include "pycore_object.h"
#include <stddef.h> // offsetof()
#include "_iomodule.h"
PyObject *b;
if (peek != NULL) {
- PyObject *readahead = PyObject_CallOneArg(peek, _PyLong_One);
+ PyObject *readahead = PyObject_CallOneArg(peek, _PyLong_GetOne());
if (readahead == NULL) {
/* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals()
when EINTR occurs so we needn't do it ourselves. */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "pycore_interp.h" // PyInterpreterState.fs_codec
+#include "pycore_long.h" // _PyLong_GetZero()
#include "pycore_object.h"
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "structmember.h" // PyMemberDef
return -1;
}
- int cmp = PyObject_RichCompareBool(cookieObj, _PyLong_Zero, Py_EQ);
+ int cmp = PyObject_RichCompareBool(cookieObj, _PyLong_GetZero(), Py_EQ);
Py_DECREF(cookieObj);
if (cmp < 0) {
return -1;
if (cmp == 0) {
self->encoding_start_of_stream = 0;
PyObject *res = PyObject_CallMethodOneArg(
- self->encoder, _PyIO_str_setstate, _PyLong_Zero);
+ self->encoder, _PyIO_str_setstate, _PyLong_GetZero());
if (res == NULL) {
return -1;
}
}
else {
res = PyObject_CallMethodOneArg(self->encoder, _PyIO_str_setstate,
- _PyLong_Zero);
+ _PyLong_GetZero());
self->encoding_start_of_stream = 0;
}
if (res == NULL)
goto fail;
}
+ PyObject *zero = _PyLong_GetZero(); // borrowed reference
+
switch (whence) {
case SEEK_CUR:
/* seek relative to current position */
- cmp = PyObject_RichCompareBool(cookieObj, _PyLong_Zero, Py_EQ);
+ cmp = PyObject_RichCompareBool(cookieObj, zero, Py_EQ);
if (cmp < 0)
goto fail;
case SEEK_END:
/* seek relative to end of file */
- cmp = PyObject_RichCompareBool(cookieObj, _PyLong_Zero, Py_EQ);
+ cmp = PyObject_RichCompareBool(cookieObj, zero, Py_EQ);
if (cmp < 0)
goto fail;
goto fail;
if (self->encoder) {
/* If seek() == 0, we are at the start of stream, otherwise not */
- cmp = PyObject_RichCompareBool(res, _PyLong_Zero, Py_EQ);
+ cmp = PyObject_RichCompareBool(res, zero, Py_EQ);
if (cmp < 0 || _textiowrapper_encoder_reset(self, cmp)) {
Py_DECREF(res);
goto fail;
goto fail;
}
- cmp = PyObject_RichCompareBool(cookieObj, _PyLong_Zero, Py_LT);
+ cmp = PyObject_RichCompareBool(cookieObj, zero, Py_LT);
if (cmp < 0)
goto fail;
#define PY_SSIZE_T_CLEAN
#include "Python.h"
+#include "pycore_long.h" // _PyLong_GetZero()
#include "structmember.h" // PyMemberDef
#include "sre.h"
switch (size) {
case 0:
- result = match_getslice(self, _PyLong_Zero, Py_None);
+ result = match_getslice(self, _PyLong_GetZero(), Py_None);
break;
case 1:
result = match_getslice(self, PyTuple_GET_ITEM(args, 0), Py_None);
#include "Python.h"
+#include "pycore_long.h" // _PyLong_GetOne()
#include "structmember.h"
#include <ctype.h>
}
dt = NULL;
- if (!PyDict_SetItemString(kwargs, "fold", _PyLong_One)) {
+ if (!PyDict_SetItemString(kwargs, "fold", _PyLong_GetOne())) {
dt = PyObject_Call(replace, args, kwargs);
}
{
PyObject *return_value = NULL;
int group_right_1 = 0;
- PyObject *verch = _PyLong_Zero;
- PyObject *horch = _PyLong_Zero;
+ PyObject *verch = _PyLong_GetZero();
+ PyObject *horch = _PyLong_GetZero();
switch (PyTuple_GET_SIZE(args)) {
case 0:
#ifndef _CURSES_USE_DEFAULT_COLORS_METHODDEF
#define _CURSES_USE_DEFAULT_COLORS_METHODDEF
#endif /* !defined(_CURSES_USE_DEFAULT_COLORS_METHODDEF) */
-/*[clinic end generated code: output=38b2531d17f119e1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=92bad2172fef9747 input=a9049054013a1b77]*/
#define PY_SSIZE_T_CLEAN
#include "Python.h"
+#include "pycore_long.h" // _PyLong_GetZero()
#include "pycore_tuple.h" // _PyTuple_ITEMS()
#include <stddef.h> // offsetof()
}
} else {
cnt = 0;
- long_cnt = _PyLong_Zero;
+ long_cnt = _PyLong_GetZero();
}
Py_INCREF(long_cnt);
/* If not specified, step defaults to 1 */
- if (long_step == NULL)
- long_step = _PyLong_One;
+ if (long_step == NULL) {
+ long_step = _PyLong_GetOne();
+ }
Py_INCREF(long_step);
assert(long_cnt != NULL && long_step != NULL);
#include "Python.h"
#include "pycore_bitutils.h" // _Py_bit_length()
#include "pycore_dtoa.h"
+#include "pycore_long.h" // _PyLong_GetZero()
#include "_math.h"
#include "clinic/mathmodule.c.h"
Py_DECREF(res);
return NULL;
}
- if (res == _PyLong_One) {
+ if (res == _PyLong_GetOne()) {
/* Fast path: just check arguments.
It is okay to use identity comparison here. */
Py_DECREF(x);
Py_DECREF(res);
return NULL;
}
- if (res == _PyLong_Zero) {
+ if (res == _PyLong_GetZero()) {
/* Fast path: just check arguments.
It is okay to use identity comparison here. */
Py_DECREF(x);
}
if (a_too_large) {
- Py_SETREF(a, PyNumber_Subtract(a, _PyLong_One));
+ Py_SETREF(a, PyNumber_Subtract(a, _PyLong_GetOne()));
}
Py_DECREF(n);
return a;
factor = n;
Py_INCREF(factor);
for (i = 1; i < factors; ++i) {
- Py_SETREF(factor, PyNumber_Subtract(factor, _PyLong_One));
+ Py_SETREF(factor, PyNumber_Subtract(factor, _PyLong_GetOne()));
if (factor == NULL) {
goto error;
}
factor = n;
Py_INCREF(factor);
for (i = 1; i < factors; ++i) {
- Py_SETREF(factor, PyNumber_Subtract(factor, _PyLong_One));
+ Py_SETREF(factor, PyNumber_Subtract(factor, _PyLong_GetOne()));
if (factor == NULL) {
goto error;
}
libraries=['m'],
extra_compile_args=['-DPy_BUILD_CORE_MODULE']))
# zoneinfo module
- self.add(Extension('_zoneinfo', ['_zoneinfo.c'])),
+ self.add(Extension('_zoneinfo', ['_zoneinfo.c'],
+ extra_compile_args=['-DPy_BUILD_CORE_MODULE']))
# random number generator implemented in C
self.add(Extension("_random", ["_randommodule.c"],
extra_compile_args=['-DPy_BUILD_CORE_MODULE']))
if curses_library.startswith('ncurses'):
curses_libs = [curses_library]
self.add(Extension('_curses', ['_cursesmodule.c'],
+ extra_compile_args=['-DPy_BUILD_CORE_MODULE'],
include_dirs=curses_includes,
define_macros=curses_defines,
libraries=curses_libs))
curses_libs = ['curses']
self.add(Extension('_curses', ['_cursesmodule.c'],
+ extra_compile_args=['-DPy_BUILD_CORE_MODULE'],
define_macros=curses_defines,
libraries=curses_libs))
else: