[Python-checkins] cpython (2.7): avoid name clash with posix_close (closes #20594)

benjamin.peterson python-checkins at python.org
Tue Feb 11 16:19:23 CET 2014


http://hg.python.org/cpython/rev/1d253360d5a6
changeset:   89151:1d253360d5a6
branch:      2.7
parent:      89148:41e49f1c5bd8
user:        Benjamin Peterson <benjamin at python.org>
date:        Tue Feb 11 10:16:16 2014 -0500
summary:
  avoid name clash with posix_close (closes #20594)

files:
  Misc/NEWS             |   2 ++
  Modules/posixmodule.c |  10 +++++++---
  2 files changed, 9 insertions(+), 3 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -44,6 +44,8 @@
 Library
 -------
 
+- Issue #20594: Avoid name clash with the libc function posix_close.
+
 - Issue #19856: shutil.move() failed to move a directory to other directory
   on Windows if source name ends with os.altsep.
 
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -6581,8 +6581,12 @@
 "close(fd)\n\n\
 Close a file descriptor (for low level IO).");
 
-static PyObject *
-posix_close(PyObject *self, PyObject *args)
+/*
+The underscore at end of function name avoids a name clash with the libc
+function posix_close.
+*/
+static PyObject *
+posix_close_(PyObject *self, PyObject *args)
 {
     int fd, res;
     if (!PyArg_ParseTuple(args, "i:close", &fd))
@@ -8960,7 +8964,7 @@
     {"tcsetpgrp",       posix_tcsetpgrp, METH_VARARGS, posix_tcsetpgrp__doc__},
 #endif /* HAVE_TCSETPGRP */
     {"open",            posix_open, METH_VARARGS, posix_open__doc__},
-    {"close",           posix_close, METH_VARARGS, posix_close__doc__},
+    {"close",           posix_close_, METH_VARARGS, posix_close__doc__},
     {"closerange",      posix_closerange, METH_VARARGS, posix_closerange__doc__},
     {"dup",             posix_dup, METH_VARARGS, posix_dup__doc__},
     {"dup2",            posix_dup2, METH_VARARGS, posix_dup2__doc__},

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list