Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 932bba3

Browse files
committed
avoid name clash with posix_close (closes #20594)
1 parent 3a308b9 commit 932bba3

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Core and Builtins
2020
Library
2121
-------
2222

23+
- Issue #20594: Avoid name clash with the libc function posix_close.
24+
2325
- Issue #19856: shutil.move() failed to move a directory to other directory
2426
on Windows if source name ends with os.altsep.
2527

Modules/posixmodule.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7844,8 +7844,12 @@ PyDoc_STRVAR(posix_close__doc__,
78447844
"close(fd)\n\n\
78457845
Close a file descriptor (for low level IO).");
78467846

7847+
/*
7848+
The underscore at end of function name avoids a name clash with the libc
7849+
function posix_close.
7850+
*/
78477851
static PyObject *
7848-
posix_close(PyObject *self, PyObject *args)
7852+
posix_close_(PyObject *self, PyObject *args)
78497853
{
78507854
int fd, res;
78517855
if (!PyArg_ParseTuple(args, "i:close", &fd))
@@ -11261,7 +11265,7 @@ static PyMethodDef posix_methods[] = {
1126111265
{"open", (PyCFunction)posix_open,\
1126211266
METH_VARARGS | METH_KEYWORDS,
1126311267
posix_open__doc__},
11264-
{"close", posix_close, METH_VARARGS, posix_close__doc__},
11268+
{"close", posix_close_, METH_VARARGS, posix_close__doc__},
1126511269
{"closerange", posix_closerange, METH_VARARGS, posix_closerange__doc__},
1126611270
{"device_encoding", device_encoding, METH_VARARGS, device_encoding__doc__},
1126711271
{"dup", posix_dup, METH_VARARGS, posix_dup__doc__},

0 commit comments

Comments
 (0)