changeset 48841:2ef3b7d30cc1

cext: really remove Python 2 file handling code Disclaimer: This is _WIN32 code and I have no machine to test.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 03 Mar 2022 09:45:21 +0900
parents 499733de460f
children 649ff7f86f96
files mercurial/cext/osutil.c
diffstat 1 files changed, 0 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cext/osutil.c	Thu Mar 03 09:43:10 2022 +0900
+++ b/mercurial/cext/osutil.c	Thu Mar 03 09:45:21 2022 +0900
@@ -1176,9 +1176,6 @@
 	char fpmode[4];
 	int fppos = 0;
 	int plus;
-#ifndef IS_PY3K
-	FILE *fp;
-#endif
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwds, "et|yi:posixfile",
 					 kwlist,
@@ -1250,26 +1247,9 @@
 		PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
 		goto bail;
 	}
-#ifndef IS_PY3K
-	fp = _fdopen(fd, fpmode);
-	if (fp == NULL) {
-		_close(fd);
-		PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
-		goto bail;
-	}
-
-	file_obj = PyFile_FromFile(fp, name, mode, fclose);
-	if (file_obj == NULL) {
-		fclose(fp);
-		goto bail;
-	}
-
-	PyFile_SetBufSize(file_obj, bufsize);
-#else
 	file_obj = PyFile_FromFd(fd, name, mode, bufsize, NULL, NULL, NULL, 1);
 	if (file_obj == NULL)
 		goto bail;
-#endif
 bail:
 	PyMem_Free(name);
 	return file_obj;