Details
Details
- Reviewers
Alphare - Group Reviewers
hg-reviewers - Commits
- rHGe9ca736f5b52: cext: remove Python 2 file handling code
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
( )
Alphare |
hg-reviewers |
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/cext/osutil.c (8 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
bd7a6a0a86ae | b403d6e1560e | Gregory Szorc | Feb 20 2022, 5:45 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | indygreg | ||
Closed | indygreg | D12232 cext: remove PY23() | |
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | D12229 cext: use PyLong symbols | |
Closed | indygreg | D12228 cext: use PyLong symbols | |
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg |
DWORD creation; | DWORD creation; | ||||
HANDLE handle; | HANDLE handle; | ||||
int fd, flags = 0; | int fd, flags = 0; | ||||
int bufsize = -1; | int bufsize = -1; | ||||
char m0, m1, m2; | char m0, m1, m2; | ||||
char fpmode[4]; | char fpmode[4]; | ||||
int fppos = 0; | int fppos = 0; | ||||
int plus; | int plus; | ||||
#ifndef IS_PY3K | |||||
FILE *fp; | FILE *fp; | ||||
#endif | |||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, PY23("et|si:posixfile", | if (!PyArg_ParseTupleAndKeywords(args, kwds, PY23("et|si:posixfile", | ||||
"et|yi:posixfile"), | "et|yi:posixfile"), | ||||
kwlist, | kwlist, | ||||
Py_FileSystemDefaultEncoding, | Py_FileSystemDefaultEncoding, | ||||
&name, &mode, &bufsize)) | &name, &mode, &bufsize)) | ||||
return NULL; | return NULL; | ||||
fd = _open_osfhandle((intptr_t)handle, flags); | fd = _open_osfhandle((intptr_t)handle, flags); | ||||
if (fd == -1) { | if (fd == -1) { | ||||
CloseHandle(handle); | CloseHandle(handle); | ||||
PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); | PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); | ||||
goto bail; | goto bail; | ||||
} | } | ||||
#ifndef IS_PY3K | |||||
fp = _fdopen(fd, fpmode); | fp = _fdopen(fd, fpmode); | ||||
if (fp == NULL) { | if (fp == NULL) { | ||||
_close(fd); | _close(fd); | ||||
PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); | PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); | ||||
goto bail; | goto bail; | ||||
} | } | ||||
file_obj = PyFile_FromFile(fp, name, mode, fclose); | file_obj = PyFile_FromFile(fp, name, mode, fclose); | ||||
if (file_obj == NULL) { | if (file_obj == NULL) { | ||||
fclose(fp); | fclose(fp); | ||||
goto bail; | goto bail; | ||||
} | } | ||||
PyFile_SetBufSize(file_obj, bufsize); | 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: | bail: | ||||
PyMem_Free(name); | PyMem_Free(name); | ||||
return file_obj; | return file_obj; | ||||
} | } | ||||
#endif | #endif | ||||
#ifdef __APPLE__ | #ifdef __APPLE__ | ||||
#include <ApplicationServices/ApplicationServices.h> | #include <ApplicationServices/ApplicationServices.h> |