components/python/python26/patches/Python26-25-closerange.patch
changeset 841 1a62cefa636d
parent 578 4f51372decaf
--- a/components/python/python26/patches/Python26-25-closerange.patch	Wed May 30 10:46:29 2012 -0700
+++ b/components/python/python26/patches/Python26-25-closerange.patch	Wed May 30 12:40:14 2012 -0700
@@ -1,39 +1,39 @@
---- Python-2.6.4/Modules/posixmodule.c	Wed Sep 16 13:06:36 2009
-+++ Python-2.6.4/Modules/posixmodule.c	Thu Nov  3 17:39:15 2011
-@@ -6295,15 +6297,34 @@
+--- Python-2.6.8/Modules/posixmodule.c.orig	2012-05-14 06:31:28.561995103 -0700
++++ Python-2.6.8/Modules/posixmodule.c	2012-05-14 06:34:39.031503970 -0700
+@@ -6378,15 +6378,34 @@
  "closerange(fd_low, fd_high)\n\n\
  Closes all file descriptors in [fd_low, fd_high), ignoring errors.");
  
 +static int
 +close_func(void *lohi, int fd)
 +{
-+	int lo = ((int *)lohi)[0];
-+	int hi = ((int *)lohi)[1];
++    int lo = ((int *)lohi)[0];
++    int hi = ((int *)lohi)[1];
 +
-+	if (fd >= hi)
-+		return (1);
-+	else if (fd >= lo)
-+		close(fd);
++    if (fd >= hi)
++        return (1);
++    else if (fd >= lo)
++        close(fd);
 +
-+	return (0);
++    return (0);
 +}
 +
  static PyObject *
  posix_closerange(PyObject *self, PyObject *args)
  {
- 	int fd_from, fd_to, i;
-+	int lohi[2];
+     int fd_from, fd_to, i;
++    int lohi[2];
 +
- 	if (!PyArg_ParseTuple(args, "ii:closerange", &fd_from, &fd_to))
- 		return NULL;
- 	Py_BEGIN_ALLOW_THREADS
--	for (i = fd_from; i < fd_to; i++)
--		close(i);
+     if (!PyArg_ParseTuple(args, "ii:closerange", &fd_from, &fd_to))
+         return NULL;
+     Py_BEGIN_ALLOW_THREADS
+-    for (i = fd_from; i < fd_to; i++)
+-        close(i);
 +
-+	lohi[0] = fd_from;
-+	lohi[1] = fd_to;
-+	fdwalk(close_func, lohi);
++    lohi[0] = fd_from;
++    lohi[1] = fd_to;
++    fdwalk(close_func, lohi);
 +
- 	Py_END_ALLOW_THREADS
- 	Py_RETURN_NONE;
+     Py_END_ALLOW_THREADS
+     Py_RETURN_NONE;
  }