Skip to content

Commit 61a9192

Browse files
committed
pythongh-108444: Replace _PyLong_AsInt() with PyLong_AsInt()
Change generated by the command: sed -i -e 's!_PyLong_AsInt!PyLong_AsInt!g' \ $(find -name "*.c" -o -name "*.h")
1 parent be436e0 commit 61a9192

18 files changed

+32
-32
lines changed

Modules/_csv.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ _set_int(const char *name, int *target, PyObject *src, int dflt)
233233
"\"%s\" must be an integer", name);
234234
return -1;
235235
}
236-
value = _PyLong_AsInt(src);
236+
value = PyLong_AsInt(src);
237237
if (value == -1 && PyErr_Occurred()) {
238238
return -1;
239239
}

Modules/_ctypes/stgdict.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
401401
return -1;
402402
}
403403
if (tmp) {
404-
pack = _PyLong_AsInt(tmp);
404+
pack = PyLong_AsInt(tmp);
405405
Py_DECREF(tmp);
406406
if (pack < 0) {
407407
if (!PyErr_Occurred() ||

Modules/_datetimemodule.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,7 @@ microseconds_to_delta_ex(PyObject *pyus, PyTypeObject *type)
19231923
}
19241924

19251925
num = PyTuple_GET_ITEM(tuple, 1); /* us */
1926-
us = _PyLong_AsInt(num);
1926+
us = PyLong_AsInt(num);
19271927
num = NULL;
19281928
if (us == -1 && PyErr_Occurred()) {
19291929
goto Done;
@@ -1941,7 +1941,7 @@ microseconds_to_delta_ex(PyObject *pyus, PyTypeObject *type)
19411941
Py_DECREF(num);
19421942

19431943
num = PyTuple_GET_ITEM(tuple, 1); /* seconds */
1944-
s = _PyLong_AsInt(num);
1944+
s = PyLong_AsInt(num);
19451945
num = NULL;
19461946
if (s == -1 && PyErr_Occurred()) {
19471947
goto Done;
@@ -1951,7 +1951,7 @@ microseconds_to_delta_ex(PyObject *pyus, PyTypeObject *type)
19511951
}
19521952

19531953
num = Py_NewRef(PyTuple_GET_ITEM(tuple, 0)); /* leftover days */
1954-
d = _PyLong_AsInt(num);
1954+
d = PyLong_AsInt(num);
19551955
if (d == -1 && PyErr_Occurred()) {
19561956
goto Done;
19571957
}

Modules/_io/fileio.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
264264
self->fd = -1;
265265
}
266266

267-
fd = _PyLong_AsInt(nameobj);
267+
fd = PyLong_AsInt(nameobj);
268268
if (fd < 0) {
269269
if (!PyErr_Occurred()) {
270270
PyErr_SetString(PyExc_ValueError,
@@ -412,7 +412,7 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
412412
goto error;
413413
}
414414

415-
self->fd = _PyLong_AsInt(fdobj);
415+
self->fd = PyLong_AsInt(fdobj);
416416
Py_DECREF(fdobj);
417417
if (self->fd < 0) {
418418
if (!PyErr_Occurred()) {

Modules/_io/winconsoleio.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ _io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj,
280280
self->fd = -1;
281281
}
282282

283-
fd = _PyLong_AsInt(nameobj);
283+
fd = PyLong_AsInt(nameobj);
284284
if (fd < 0) {
285285
if (!PyErr_Occurred()) {
286286
PyErr_SetString(PyExc_ValueError,

Modules/_sqlite/connection.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,7 @@ authorizer_callback(void *ctx, int action, const char *arg1,
13961396
}
13971397
else {
13981398
if (PyLong_Check(ret)) {
1399-
rc = _PyLong_AsInt(ret);
1399+
rc = PyLong_AsInt(ret);
14001400
if (rc == -1 && PyErr_Occurred()) {
14011401
print_or_clear_traceback(ctx);
14021402
rc = SQLITE_DENY;

Modules/faulthandler.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ faulthandler_get_fileno(PyObject **file_ptr)
116116
}
117117
}
118118
else if (PyLong_Check(file)) {
119-
fd = _PyLong_AsInt(file);
119+
fd = PyLong_AsInt(file);
120120
if (fd == -1 && PyErr_Occurred())
121121
return -1;
122122
if (fd < 0) {

Modules/posixmodule.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -6821,7 +6821,7 @@ parse_posix_spawn_flags(PyObject *module, const char *func_name, PyObject *setpg
68216821
goto fail;
68226822
}
68236823
if (py_schedpolicy != Py_None) {
6824-
int schedpolicy = _PyLong_AsInt(py_schedpolicy);
6824+
int schedpolicy = PyLong_AsInt(py_schedpolicy);
68256825

68266826
if (schedpolicy == -1 && PyErr_Occurred()) {
68276827
goto fail;
@@ -12484,7 +12484,7 @@ conv_confname(PyObject *arg, int *valuep, struct constdef *table,
1248412484
size_t tablesize)
1248512485
{
1248612486
if (PyLong_Check(arg)) {
12487-
int value = _PyLong_AsInt(arg);
12487+
int value = PyLong_AsInt(arg);
1248812488
if (value == -1 && PyErr_Occurred())
1248912489
return 0;
1249012490
*valuep = value;
@@ -15668,7 +15668,7 @@ os_waitstatus_to_exitcode_impl(PyObject *module, PyObject *status_obj)
1566815668
/*[clinic end generated code: output=db50b1b0ba3c7153 input=7fe2d7fdaea3db42]*/
1566915669
{
1567015670
#ifndef MS_WINDOWS
15671-
int status = _PyLong_AsInt(status_obj);
15671+
int status = PyLong_AsInt(status_obj);
1567215672
if (status == -1 && PyErr_Occurred()) {
1567315673
return NULL;
1567415674
}

Modules/readline.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ on_hook(PyObject *func)
10011001
if (r == Py_None)
10021002
result = 0;
10031003
else {
1004-
result = _PyLong_AsInt(r);
1004+
result = PyLong_AsInt(r);
10051005
if (result == -1 && PyErr_Occurred())
10061006
goto error;
10071007
}

Modules/socketmodule.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -4879,17 +4879,17 @@ sock_sendmsg_afalg(PySocketSockObject *self, PyObject *args, PyObject *kwds)
48794879

48804880
/* op is a required, keyword-only argument >= 0 */
48814881
if (opobj != NULL) {
4882-
op = _PyLong_AsInt(opobj);
4882+
op = PyLong_AsInt(opobj);
48834883
}
48844884
if (op < 0) {
4885-
/* override exception from _PyLong_AsInt() */
4885+
/* override exception from PyLong_AsInt() */
48864886
PyErr_SetString(PyExc_TypeError,
48874887
"Invalid or missing argument 'op'");
48884888
goto finally;
48894889
}
48904890
/* assoclen is optional but must be >= 0 */
48914891
if (assoclenobj != NULL) {
4892-
assoclen = _PyLong_AsInt(assoclenobj);
4892+
assoclen = PyLong_AsInt(assoclenobj);
48934893
if (assoclen == -1 && PyErr_Occurred()) {
48944894
goto finally;
48954895
}
@@ -5007,7 +5007,7 @@ sock_shutdown(PySocketSockObject *s, PyObject *arg)
50075007
int how;
50085008
int res;
50095009

5010-
how = _PyLong_AsInt(arg);
5010+
how = PyLong_AsInt(arg);
50115011
if (how == -1 && PyErr_Occurred())
50125012
return NULL;
50135013
Py_BEGIN_ALLOW_THREADS

Objects/bytesobject.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
753753
"* wants int");
754754
goto error;
755755
}
756-
prec = _PyLong_AsInt(v);
756+
prec = PyLong_AsInt(v);
757757
if (prec == -1 && PyErr_Occurred())
758758
goto error;
759759
if (prec < 0)

Objects/fileobject.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ PyObject_AsFileDescriptor(PyObject *o)
174174
PyObject *meth;
175175

176176
if (PyLong_Check(o)) {
177-
fd = _PyLong_AsInt(o);
177+
fd = PyLong_AsInt(o);
178178
}
179179
else if (PyObject_GetOptionalAttr(o, &_Py_ID(fileno), &meth) < 0) {
180180
return -1;
@@ -186,7 +186,7 @@ PyObject_AsFileDescriptor(PyObject *o)
186186
return -1;
187187

188188
if (PyLong_Check(fno)) {
189-
fd = _PyLong_AsInt(fno);
189+
fd = PyLong_AsInt(fno);
190190
Py_DECREF(fno);
191191
}
192192
else {

Objects/unicodeobject.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14034,7 +14034,7 @@ unicode_format_arg_parse(struct unicode_formatter_t *ctx,
1403414034
"* wants int");
1403514035
return -1;
1403614036
}
14037-
arg->prec = _PyLong_AsInt(v);
14037+
arg->prec = PyLong_AsInt(v);
1403814038
if (arg->prec == -1 && PyErr_Occurred())
1403914039
return -1;
1404014040
if (arg->prec < 0)

Python/assemble.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ compute_localsplus_info(_PyCompile_CodeUnitMetadata *umd, int nlocalsplus,
476476
PyObject *k, *v;
477477
Py_ssize_t pos = 0;
478478
while (PyDict_Next(umd->u_varnames, &pos, &k, &v)) {
479-
int offset = _PyLong_AsInt(v);
479+
int offset = PyLong_AsInt(v);
480480
if (offset == -1 && PyErr_Occurred()) {
481481
return ERROR;
482482
}
@@ -513,7 +513,7 @@ compute_localsplus_info(_PyCompile_CodeUnitMetadata *umd, int nlocalsplus,
513513
continue;
514514
}
515515

516-
int offset = _PyLong_AsInt(v);
516+
int offset = PyLong_AsInt(v);
517517
if (offset == -1 && PyErr_Occurred()) {
518518
return ERROR;
519519
}
@@ -525,7 +525,7 @@ compute_localsplus_info(_PyCompile_CodeUnitMetadata *umd, int nlocalsplus,
525525

526526
pos = 0;
527527
while (PyDict_Next(umd->u_freevars, &pos, &k, &v)) {
528-
int offset = _PyLong_AsInt(v);
528+
int offset = PyLong_AsInt(v);
529529
if (offset == -1 && PyErr_Occurred()) {
530530
return ERROR;
531531
}

Python/ceval.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2416,7 +2416,7 @@ import_name(PyThreadState *tstate, _PyInterpreterFrame *frame,
24162416

24172417
/* Fast path for not overloaded __import__. */
24182418
if (_PyImport_IsDefaultImportFunc(tstate->interp, import_func)) {
2419-
int ilevel = _PyLong_AsInt(level);
2419+
int ilevel = PyLong_AsInt(level);
24202420
if (ilevel == -1 && _PyErr_Occurred(tstate)) {
24212421
return NULL;
24222422
}

Python/flowgraph.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2412,13 +2412,13 @@ build_cellfixedoffsets(_PyCompile_CodeUnitMetadata *umd)
24122412
continue;
24132413
}
24142414

2415-
int argoffset = _PyLong_AsInt(varindex);
2415+
int argoffset = PyLong_AsInt(varindex);
24162416
Py_DECREF(varindex);
24172417
if (argoffset == -1 && PyErr_Occurred()) {
24182418
goto error;
24192419
}
24202420

2421-
int oldindex = _PyLong_AsInt(cellindex);
2421+
int oldindex = PyLong_AsInt(cellindex);
24222422
if (oldindex == -1 && PyErr_Occurred()) {
24232423
goto error;
24242424
}

Python/initconfig.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ config_dict_get_int(PyObject *dict, const char *name, int *result)
10971097
if (item == NULL) {
10981098
return -1;
10991099
}
1100-
int value = _PyLong_AsInt(item);
1100+
int value = PyLong_AsInt(item);
11011101
Py_DECREF(item);
11021102
if (value == -1 && PyErr_Occurred()) {
11031103
if (PyErr_ExceptionMatches(PyExc_TypeError)) {

Python/legacy_tracing.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ sys_trace_line_func(
256256
Py_RETURN_NONE;
257257
}
258258
assert(PyVectorcall_NARGS(nargsf) == 2);
259-
int line = _PyLong_AsInt(args[1]);
259+
int line = PyLong_AsInt(args[1]);
260260
assert(line >= 0);
261261
PyFrameObject *frame = PyEval_GetFrame();
262262
if (frame == NULL) {
@@ -282,9 +282,9 @@ sys_trace_jump_func(
282282
Py_RETURN_NONE;
283283
}
284284
assert(PyVectorcall_NARGS(nargsf) == 3);
285-
int from = _PyLong_AsInt(args[1])/sizeof(_Py_CODEUNIT);
285+
int from = PyLong_AsInt(args[1])/sizeof(_Py_CODEUNIT);
286286
assert(from >= 0);
287-
int to = _PyLong_AsInt(args[2])/sizeof(_Py_CODEUNIT);
287+
int to = PyLong_AsInt(args[2])/sizeof(_Py_CODEUNIT);
288288
assert(to >= 0);
289289
if (to > from) {
290290
/* Forward jump */

0 commit comments

Comments
 (0)