Skip to content

Commit b32d4ca

Browse files
authored
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")
1 parent 4e5a728 commit b32d4ca

18 files changed

+32
-32
lines changed

Modules/_csv.c

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

0 commit comments

Comments
 (0)