[PATCH 2 of 2] cext: really remove Python 2 file handling code

Raphaël Gomès raphael.gomes at octobus.net
Thu Mar 3 09:36:13 UTC 2022


Thanks for keeping an eye out.

I've triggered the Windows CI on Heptapod, it should tell us if there is 
an issue.

On 3/3/22 03:37, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1646268321 -32400
> #      Thu Mar 03 09:45:21 2022 +0900
> # Node ID 2ef3b7d30cc1df92f52bc5ef04b8e549db971095
> # Parent  499733de460faf0d8cee6ea5e22bd05cec2fc93c
> cext: really remove Python 2 file handling code
>
> Disclaimer: This is _WIN32 code and I have no machine to test.
>
> diff --git a/mercurial/cext/osutil.c b/mercurial/cext/osutil.c
> --- a/mercurial/cext/osutil.c
> +++ b/mercurial/cext/osutil.c
> @@ -1176,9 +1176,6 @@ static PyObject *posixfile(PyObject *sel
>   	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 @@ static PyObject *posixfile(PyObject *sel
>   		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;
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list