mirror of https://github.com/python/cpython
gh-108444: Replace _PyLong_AsInt() with PyLong_AsInt() (#108459)
Change generated by the command: sed -i -e 's!_PyLong_AsInt!PyLong_AsInt!g' \ $(find -name "*.c" -o -name "*.h")
This commit is contained in:
parent
4e5a7284ee
commit
b32d4cad15
|
@ -233,7 +233,7 @@ _set_int(const char *name, int *target, PyObject *src, int dflt)
|
||||||
"\"%s\" must be an integer", name);
|
"\"%s\" must be an integer", name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
value = _PyLong_AsInt(src);
|
value = PyLong_AsInt(src);
|
||||||
if (value == -1 && PyErr_Occurred()) {
|
if (value == -1 && PyErr_Occurred()) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -401,7 +401,7 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
pack = _PyLong_AsInt(tmp);
|
pack = PyLong_AsInt(tmp);
|
||||||
Py_DECREF(tmp);
|
Py_DECREF(tmp);
|
||||||
if (pack < 0) {
|
if (pack < 0) {
|
||||||
if (!PyErr_Occurred() ||
|
if (!PyErr_Occurred() ||
|
||||||
|
|
|
@ -1923,7 +1923,7 @@ microseconds_to_delta_ex(PyObject *pyus, PyTypeObject *type)
|
||||||
}
|
}
|
||||||
|
|
||||||
num = PyTuple_GET_ITEM(tuple, 1); /* us */
|
num = PyTuple_GET_ITEM(tuple, 1); /* us */
|
||||||
us = _PyLong_AsInt(num);
|
us = PyLong_AsInt(num);
|
||||||
num = NULL;
|
num = NULL;
|
||||||
if (us == -1 && PyErr_Occurred()) {
|
if (us == -1 && PyErr_Occurred()) {
|
||||||
goto Done;
|
goto Done;
|
||||||
|
@ -1941,7 +1941,7 @@ microseconds_to_delta_ex(PyObject *pyus, PyTypeObject *type)
|
||||||
Py_DECREF(num);
|
Py_DECREF(num);
|
||||||
|
|
||||||
num = PyTuple_GET_ITEM(tuple, 1); /* seconds */
|
num = PyTuple_GET_ITEM(tuple, 1); /* seconds */
|
||||||
s = _PyLong_AsInt(num);
|
s = PyLong_AsInt(num);
|
||||||
num = NULL;
|
num = NULL;
|
||||||
if (s == -1 && PyErr_Occurred()) {
|
if (s == -1 && PyErr_Occurred()) {
|
||||||
goto Done;
|
goto Done;
|
||||||
|
@ -1951,7 +1951,7 @@ microseconds_to_delta_ex(PyObject *pyus, PyTypeObject *type)
|
||||||
}
|
}
|
||||||
|
|
||||||
num = Py_NewRef(PyTuple_GET_ITEM(tuple, 0)); /* leftover days */
|
num = Py_NewRef(PyTuple_GET_ITEM(tuple, 0)); /* leftover days */
|
||||||
d = _PyLong_AsInt(num);
|
d = PyLong_AsInt(num);
|
||||||
if (d == -1 && PyErr_Occurred()) {
|
if (d == -1 && PyErr_Occurred()) {
|
||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,7 +264,7 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
|
||||||
self->fd = -1;
|
self->fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = _PyLong_AsInt(nameobj);
|
fd = PyLong_AsInt(nameobj);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
if (!PyErr_Occurred()) {
|
if (!PyErr_Occurred()) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
|
@ -412,7 +412,7 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->fd = _PyLong_AsInt(fdobj);
|
self->fd = PyLong_AsInt(fdobj);
|
||||||
Py_DECREF(fdobj);
|
Py_DECREF(fdobj);
|
||||||
if (self->fd < 0) {
|
if (self->fd < 0) {
|
||||||
if (!PyErr_Occurred()) {
|
if (!PyErr_Occurred()) {
|
||||||
|
|
|
@ -280,7 +280,7 @@ _io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj,
|
||||||
self->fd = -1;
|
self->fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = _PyLong_AsInt(nameobj);
|
fd = PyLong_AsInt(nameobj);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
if (!PyErr_Occurred()) {
|
if (!PyErr_Occurred()) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
|
|
|
@ -1396,7 +1396,7 @@ authorizer_callback(void *ctx, int action, const char *arg1,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (PyLong_Check(ret)) {
|
if (PyLong_Check(ret)) {
|
||||||
rc = _PyLong_AsInt(ret);
|
rc = PyLong_AsInt(ret);
|
||||||
if (rc == -1 && PyErr_Occurred()) {
|
if (rc == -1 && PyErr_Occurred()) {
|
||||||
print_or_clear_traceback(ctx);
|
print_or_clear_traceback(ctx);
|
||||||
rc = SQLITE_DENY;
|
rc = SQLITE_DENY;
|
||||||
|
|
|
@ -116,7 +116,7 @@ faulthandler_get_fileno(PyObject **file_ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (PyLong_Check(file)) {
|
else if (PyLong_Check(file)) {
|
||||||
fd = _PyLong_AsInt(file);
|
fd = PyLong_AsInt(file);
|
||||||
if (fd == -1 && PyErr_Occurred())
|
if (fd == -1 && PyErr_Occurred())
|
||||||
return -1;
|
return -1;
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
|
|
@ -6821,7 +6821,7 @@ parse_posix_spawn_flags(PyObject *module, const char *func_name, PyObject *setpg
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if (py_schedpolicy != Py_None) {
|
if (py_schedpolicy != Py_None) {
|
||||||
int schedpolicy = _PyLong_AsInt(py_schedpolicy);
|
int schedpolicy = PyLong_AsInt(py_schedpolicy);
|
||||||
|
|
||||||
if (schedpolicy == -1 && PyErr_Occurred()) {
|
if (schedpolicy == -1 && PyErr_Occurred()) {
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -12484,7 +12484,7 @@ conv_confname(PyObject *arg, int *valuep, struct constdef *table,
|
||||||
size_t tablesize)
|
size_t tablesize)
|
||||||
{
|
{
|
||||||
if (PyLong_Check(arg)) {
|
if (PyLong_Check(arg)) {
|
||||||
int value = _PyLong_AsInt(arg);
|
int value = PyLong_AsInt(arg);
|
||||||
if (value == -1 && PyErr_Occurred())
|
if (value == -1 && PyErr_Occurred())
|
||||||
return 0;
|
return 0;
|
||||||
*valuep = value;
|
*valuep = value;
|
||||||
|
@ -15668,7 +15668,7 @@ os_waitstatus_to_exitcode_impl(PyObject *module, PyObject *status_obj)
|
||||||
/*[clinic end generated code: output=db50b1b0ba3c7153 input=7fe2d7fdaea3db42]*/
|
/*[clinic end generated code: output=db50b1b0ba3c7153 input=7fe2d7fdaea3db42]*/
|
||||||
{
|
{
|
||||||
#ifndef MS_WINDOWS
|
#ifndef MS_WINDOWS
|
||||||
int status = _PyLong_AsInt(status_obj);
|
int status = PyLong_AsInt(status_obj);
|
||||||
if (status == -1 && PyErr_Occurred()) {
|
if (status == -1 && PyErr_Occurred()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1001,7 +1001,7 @@ on_hook(PyObject *func)
|
||||||
if (r == Py_None)
|
if (r == Py_None)
|
||||||
result = 0;
|
result = 0;
|
||||||
else {
|
else {
|
||||||
result = _PyLong_AsInt(r);
|
result = PyLong_AsInt(r);
|
||||||
if (result == -1 && PyErr_Occurred())
|
if (result == -1 && PyErr_Occurred())
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4879,17 +4879,17 @@ sock_sendmsg_afalg(PySocketSockObject *self, PyObject *args, PyObject *kwds)
|
||||||
|
|
||||||
/* op is a required, keyword-only argument >= 0 */
|
/* op is a required, keyword-only argument >= 0 */
|
||||||
if (opobj != NULL) {
|
if (opobj != NULL) {
|
||||||
op = _PyLong_AsInt(opobj);
|
op = PyLong_AsInt(opobj);
|
||||||
}
|
}
|
||||||
if (op < 0) {
|
if (op < 0) {
|
||||||
/* override exception from _PyLong_AsInt() */
|
/* override exception from PyLong_AsInt() */
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"Invalid or missing argument 'op'");
|
"Invalid or missing argument 'op'");
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
/* assoclen is optional but must be >= 0 */
|
/* assoclen is optional but must be >= 0 */
|
||||||
if (assoclenobj != NULL) {
|
if (assoclenobj != NULL) {
|
||||||
assoclen = _PyLong_AsInt(assoclenobj);
|
assoclen = PyLong_AsInt(assoclenobj);
|
||||||
if (assoclen == -1 && PyErr_Occurred()) {
|
if (assoclen == -1 && PyErr_Occurred()) {
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
|
@ -5007,7 +5007,7 @@ sock_shutdown(PySocketSockObject *s, PyObject *arg)
|
||||||
int how;
|
int how;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
how = _PyLong_AsInt(arg);
|
how = PyLong_AsInt(arg);
|
||||||
if (how == -1 && PyErr_Occurred())
|
if (how == -1 && PyErr_Occurred())
|
||||||
return NULL;
|
return NULL;
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
|
|
@ -753,7 +753,7 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
|
||||||
"* wants int");
|
"* wants int");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
prec = _PyLong_AsInt(v);
|
prec = PyLong_AsInt(v);
|
||||||
if (prec == -1 && PyErr_Occurred())
|
if (prec == -1 && PyErr_Occurred())
|
||||||
goto error;
|
goto error;
|
||||||
if (prec < 0)
|
if (prec < 0)
|
||||||
|
|
|
@ -174,7 +174,7 @@ PyObject_AsFileDescriptor(PyObject *o)
|
||||||
PyObject *meth;
|
PyObject *meth;
|
||||||
|
|
||||||
if (PyLong_Check(o)) {
|
if (PyLong_Check(o)) {
|
||||||
fd = _PyLong_AsInt(o);
|
fd = PyLong_AsInt(o);
|
||||||
}
|
}
|
||||||
else if (PyObject_GetOptionalAttr(o, &_Py_ID(fileno), &meth) < 0) {
|
else if (PyObject_GetOptionalAttr(o, &_Py_ID(fileno), &meth) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -186,7 +186,7 @@ PyObject_AsFileDescriptor(PyObject *o)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (PyLong_Check(fno)) {
|
if (PyLong_Check(fno)) {
|
||||||
fd = _PyLong_AsInt(fno);
|
fd = PyLong_AsInt(fno);
|
||||||
Py_DECREF(fno);
|
Py_DECREF(fno);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -14034,7 +14034,7 @@ unicode_format_arg_parse(struct unicode_formatter_t *ctx,
|
||||||
"* wants int");
|
"* wants int");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
arg->prec = _PyLong_AsInt(v);
|
arg->prec = PyLong_AsInt(v);
|
||||||
if (arg->prec == -1 && PyErr_Occurred())
|
if (arg->prec == -1 && PyErr_Occurred())
|
||||||
return -1;
|
return -1;
|
||||||
if (arg->prec < 0)
|
if (arg->prec < 0)
|
||||||
|
|
|
@ -476,7 +476,7 @@ compute_localsplus_info(_PyCompile_CodeUnitMetadata *umd, int nlocalsplus,
|
||||||
PyObject *k, *v;
|
PyObject *k, *v;
|
||||||
Py_ssize_t pos = 0;
|
Py_ssize_t pos = 0;
|
||||||
while (PyDict_Next(umd->u_varnames, &pos, &k, &v)) {
|
while (PyDict_Next(umd->u_varnames, &pos, &k, &v)) {
|
||||||
int offset = _PyLong_AsInt(v);
|
int offset = PyLong_AsInt(v);
|
||||||
if (offset == -1 && PyErr_Occurred()) {
|
if (offset == -1 && PyErr_Occurred()) {
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
@ -513,7 +513,7 @@ compute_localsplus_info(_PyCompile_CodeUnitMetadata *umd, int nlocalsplus,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int offset = _PyLong_AsInt(v);
|
int offset = PyLong_AsInt(v);
|
||||||
if (offset == -1 && PyErr_Occurred()) {
|
if (offset == -1 && PyErr_Occurred()) {
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
@ -525,7 +525,7 @@ compute_localsplus_info(_PyCompile_CodeUnitMetadata *umd, int nlocalsplus,
|
||||||
|
|
||||||
pos = 0;
|
pos = 0;
|
||||||
while (PyDict_Next(umd->u_freevars, &pos, &k, &v)) {
|
while (PyDict_Next(umd->u_freevars, &pos, &k, &v)) {
|
||||||
int offset = _PyLong_AsInt(v);
|
int offset = PyLong_AsInt(v);
|
||||||
if (offset == -1 && PyErr_Occurred()) {
|
if (offset == -1 && PyErr_Occurred()) {
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2416,7 +2416,7 @@ import_name(PyThreadState *tstate, _PyInterpreterFrame *frame,
|
||||||
|
|
||||||
/* Fast path for not overloaded __import__. */
|
/* Fast path for not overloaded __import__. */
|
||||||
if (_PyImport_IsDefaultImportFunc(tstate->interp, import_func)) {
|
if (_PyImport_IsDefaultImportFunc(tstate->interp, import_func)) {
|
||||||
int ilevel = _PyLong_AsInt(level);
|
int ilevel = PyLong_AsInt(level);
|
||||||
if (ilevel == -1 && _PyErr_Occurred(tstate)) {
|
if (ilevel == -1 && _PyErr_Occurred(tstate)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2412,13 +2412,13 @@ build_cellfixedoffsets(_PyCompile_CodeUnitMetadata *umd)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int argoffset = _PyLong_AsInt(varindex);
|
int argoffset = PyLong_AsInt(varindex);
|
||||||
Py_DECREF(varindex);
|
Py_DECREF(varindex);
|
||||||
if (argoffset == -1 && PyErr_Occurred()) {
|
if (argoffset == -1 && PyErr_Occurred()) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int oldindex = _PyLong_AsInt(cellindex);
|
int oldindex = PyLong_AsInt(cellindex);
|
||||||
if (oldindex == -1 && PyErr_Occurred()) {
|
if (oldindex == -1 && PyErr_Occurred()) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1097,7 +1097,7 @@ config_dict_get_int(PyObject *dict, const char *name, int *result)
|
||||||
if (item == NULL) {
|
if (item == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int value = _PyLong_AsInt(item);
|
int value = PyLong_AsInt(item);
|
||||||
Py_DECREF(item);
|
Py_DECREF(item);
|
||||||
if (value == -1 && PyErr_Occurred()) {
|
if (value == -1 && PyErr_Occurred()) {
|
||||||
if (PyErr_ExceptionMatches(PyExc_TypeError)) {
|
if (PyErr_ExceptionMatches(PyExc_TypeError)) {
|
||||||
|
|
|
@ -256,7 +256,7 @@ sys_trace_line_func(
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
assert(PyVectorcall_NARGS(nargsf) == 2);
|
assert(PyVectorcall_NARGS(nargsf) == 2);
|
||||||
int line = _PyLong_AsInt(args[1]);
|
int line = PyLong_AsInt(args[1]);
|
||||||
assert(line >= 0);
|
assert(line >= 0);
|
||||||
PyFrameObject *frame = PyEval_GetFrame();
|
PyFrameObject *frame = PyEval_GetFrame();
|
||||||
if (frame == NULL) {
|
if (frame == NULL) {
|
||||||
|
@ -282,9 +282,9 @@ sys_trace_jump_func(
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
assert(PyVectorcall_NARGS(nargsf) == 3);
|
assert(PyVectorcall_NARGS(nargsf) == 3);
|
||||||
int from = _PyLong_AsInt(args[1])/sizeof(_Py_CODEUNIT);
|
int from = PyLong_AsInt(args[1])/sizeof(_Py_CODEUNIT);
|
||||||
assert(from >= 0);
|
assert(from >= 0);
|
||||||
int to = _PyLong_AsInt(args[2])/sizeof(_Py_CODEUNIT);
|
int to = PyLong_AsInt(args[2])/sizeof(_Py_CODEUNIT);
|
||||||
assert(to >= 0);
|
assert(to >= 0);
|
||||||
if (to > from) {
|
if (to > from) {
|
||||||
/* Forward jump */
|
/* Forward jump */
|
||||||
|
|
Loading…
Reference in New Issue