Commit 26de69df authored by Victor Stinner's avatar Victor Stinner

posixmodule.c: fix function name in argument parsing

Fix os.fchown() and os.open()

Remove also trailing spaces and replace tabs by spaces.
parent eaca5c8b
...@@ -121,7 +121,7 @@ corresponding Unix manual entries for more information on calls."); ...@@ -121,7 +121,7 @@ corresponding Unix manual entries for more information on calls.");
#ifdef _MSC_VER /* Microsoft compiler */ #ifdef _MSC_VER /* Microsoft compiler */
#define HAVE_GETCWD 1 #define HAVE_GETCWD 1
#define HAVE_GETPPID 1 #define HAVE_GETPPID 1
#define HAVE_GETLOGIN 1 #define HAVE_GETLOGIN 1
#define HAVE_SPAWNV 1 #define HAVE_SPAWNV 1
#define HAVE_EXECV 1 #define HAVE_EXECV 1
#define HAVE_PIPE 1 #define HAVE_PIPE 1
...@@ -1133,11 +1133,11 @@ static int ...@@ -1133,11 +1133,11 @@ static int
win32_xstat_impl(const char *path, struct win32_stat *result, win32_xstat_impl(const char *path, struct win32_stat *result,
BOOL traverse) BOOL traverse)
{ {
int code; int code;
HANDLE hFile, hFile2; HANDLE hFile, hFile2;
BY_HANDLE_FILE_INFORMATION info; BY_HANDLE_FILE_INFORMATION info;
ULONG reparse_tag = 0; ULONG reparse_tag = 0;
wchar_t *target_path; wchar_t *target_path;
const char *dot; const char *dot;
if(!check_GetFinalPathNameByHandle()) { if(!check_GetFinalPathNameByHandle()) {
...@@ -1233,7 +1233,7 @@ win32_xstat_impl_w(const wchar_t *path, struct win32_stat *result, ...@@ -1233,7 +1233,7 @@ win32_xstat_impl_w(const wchar_t *path, struct win32_stat *result,
HANDLE hFile, hFile2; HANDLE hFile, hFile2;
BY_HANDLE_FILE_INFORMATION info; BY_HANDLE_FILE_INFORMATION info;
ULONG reparse_tag = 0; ULONG reparse_tag = 0;
wchar_t *target_path; wchar_t *target_path;
const wchar_t *dot; const wchar_t *dot;
if(!check_GetFinalPathNameByHandle()) { if(!check_GetFinalPathNameByHandle()) {
...@@ -1252,7 +1252,7 @@ win32_xstat_impl_w(const wchar_t *path, struct win32_stat *result, ...@@ -1252,7 +1252,7 @@ win32_xstat_impl_w(const wchar_t *path, struct win32_stat *result,
/* FILE_FLAG_OPEN_REPARSE_POINT does not follow the symlink. /* FILE_FLAG_OPEN_REPARSE_POINT does not follow the symlink.
Because of this, calls like GetFinalPathNameByHandle will return Because of this, calls like GetFinalPathNameByHandle will return
the symlink path agin and not the actual final path. */ the symlink path agin and not the actual final path. */
FILE_ATTRIBUTE_NORMAL|FILE_FLAG_BACKUP_SEMANTICS| FILE_ATTRIBUTE_NORMAL|FILE_FLAG_BACKUP_SEMANTICS|
FILE_FLAG_OPEN_REPARSE_POINT, FILE_FLAG_OPEN_REPARSE_POINT,
NULL); NULL);
...@@ -1371,7 +1371,7 @@ win32_stat(const char* path, struct win32_stat *result) ...@@ -1371,7 +1371,7 @@ win32_stat(const char* path, struct win32_stat *result)
return win32_xstat(path, result, TRUE); return win32_xstat(path, result, TRUE);
} }
static int static int
win32_stat_w(const wchar_t* path, struct win32_stat *result) win32_stat_w(const wchar_t* path, struct win32_stat *result)
{ {
return win32_xstat_w(path, result, TRUE); return win32_xstat_w(path, result, TRUE);
...@@ -2204,7 +2204,7 @@ posix_fchown(PyObject *self, PyObject *args) ...@@ -2204,7 +2204,7 @@ posix_fchown(PyObject *self, PyObject *args)
int fd; int fd;
long uid, gid; long uid, gid;
int res; int res;
if (!PyArg_ParseTuple(args, "ill:chown", &fd, &uid, &gid)) if (!PyArg_ParseTuple(args, "ill:fchown", &fd, &uid, &gid))
return NULL; return NULL;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
res = fchown(fd, (uid_t) uid, (gid_t) gid); res = fchown(fd, (uid_t) uid, (gid_t) gid);
...@@ -2409,7 +2409,7 @@ posix_listdir(PyObject *self, PyObject *args) ...@@ -2409,7 +2409,7 @@ posix_listdir(PyObject *self, PyObject *args)
if (PyArg_ParseTuple(args, "|U:listdir", &po)) { if (PyArg_ParseTuple(args, "|U:listdir", &po)) {
WIN32_FIND_DATAW wFileData; WIN32_FIND_DATAW wFileData;
Py_UNICODE *wnamebuf, *po_wchars; Py_UNICODE *wnamebuf, *po_wchars;
if (po == NULL) { /* Default arg: "." */ if (po == NULL) { /* Default arg: "." */
po_wchars = L"."; po_wchars = L".";
len = 1; len = 1;
...@@ -2789,7 +2789,7 @@ posix__getfinalpathname(PyObject *self, PyObject *args) ...@@ -2789,7 +2789,7 @@ posix__getfinalpathname(PyObject *self, PyObject *args)
int result_length; int result_length;
PyObject *result; PyObject *result;
wchar_t *path; wchar_t *path;
if (!PyArg_ParseTuple(args, "u|:_getfinalpathname", &path)) { if (!PyArg_ParseTuple(args, "u|:_getfinalpathname", &path)) {
return NULL; return NULL;
} }
...@@ -2810,7 +2810,7 @@ posix__getfinalpathname(PyObject *self, PyObject *args) ...@@ -2810,7 +2810,7 @@ posix__getfinalpathname(PyObject *self, PyObject *args)
/* FILE_FLAG_BACKUP_SEMANTICS is required to open a directory */ /* FILE_FLAG_BACKUP_SEMANTICS is required to open a directory */
FILE_FLAG_BACKUP_SEMANTICS, FILE_FLAG_BACKUP_SEMANTICS,
NULL); NULL);
if(hFile == INVALID_HANDLE_VALUE) { if(hFile == INVALID_HANDLE_VALUE) {
return win32_error_unicode("GetFinalPathNamyByHandle", path); return win32_error_unicode("GetFinalPathNamyByHandle", path);
return PyErr_Format(PyExc_RuntimeError, return PyErr_Format(PyExc_RuntimeError,
...@@ -3159,7 +3159,7 @@ BOOL WINAPI Py_DeleteFileW(LPCWSTR lpFileName) ...@@ -3159,7 +3159,7 @@ BOOL WINAPI Py_DeleteFileW(LPCWSTR lpFileName)
if (GetFileAttributesExW(lpFileName, GetFileExInfoStandard, &info)) { if (GetFileAttributesExW(lpFileName, GetFileExInfoStandard, &info)) {
is_directory = info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; is_directory = info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
/* Get WIN32_FIND_DATA structure for the path to determine if /* Get WIN32_FIND_DATA structure for the path to determine if
it is a symlink */ it is a symlink */
if(is_directory && if(is_directory &&
...@@ -4349,7 +4349,7 @@ posix_getgroups(PyObject *self, PyObject *noargs) ...@@ -4349,7 +4349,7 @@ posix_getgroups(PyObject *self, PyObject *noargs)
#endif #endif
gid_t grouplist[MAX_GROUPS]; gid_t grouplist[MAX_GROUPS];
/* On MacOSX getgroups(2) can return more than MAX_GROUPS results /* On MacOSX getgroups(2) can return more than MAX_GROUPS results
* This is a helper variable to store the intermediate result when * This is a helper variable to store the intermediate result when
* that happens. * that happens.
* *
...@@ -4565,15 +4565,15 @@ static PyObject * ...@@ -4565,15 +4565,15 @@ static PyObject *
posix_getlogin(PyObject *self, PyObject *noargs) posix_getlogin(PyObject *self, PyObject *noargs)
{ {
PyObject *result = NULL; PyObject *result = NULL;
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
wchar_t user_name[UNLEN + 1]; wchar_t user_name[UNLEN + 1];
DWORD num_chars = sizeof(user_name)/sizeof(user_name[0]); DWORD num_chars = sizeof(user_name)/sizeof(user_name[0]);
if (GetUserNameW(user_name, &num_chars)) { if (GetUserNameW(user_name, &num_chars)) {
/* num_chars is the number of unicode chars plus null terminator */ /* num_chars is the number of unicode chars plus null terminator */
result = PyUnicode_FromWideChar(user_name, num_chars - 1); result = PyUnicode_FromWideChar(user_name, num_chars - 1);
} }
else else
result = PyErr_SetFromWindowsErr(GetLastError()); result = PyErr_SetFromWindowsErr(GetLastError());
#else #else
char *name; char *name;
...@@ -5257,12 +5257,12 @@ win_readlink(PyObject *self, PyObject *args) ...@@ -5257,12 +5257,12 @@ win_readlink(PyObject *self, PyObject *args)
FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS,
0); 0);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
if (reparse_point_handle==INVALID_HANDLE_VALUE) if (reparse_point_handle==INVALID_HANDLE_VALUE)
{ {
return win32_error_unicode("readlink", path); return win32_error_unicode("readlink", path);
} }
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
/* New call DeviceIoControl to read the reparse point */ /* New call DeviceIoControl to read the reparse point */
io_result = DeviceIoControl( io_result = DeviceIoControl(
...@@ -5333,7 +5333,7 @@ win_symlink(PyObject *self, PyObject *args, PyObject *kwargs) ...@@ -5333,7 +5333,7 @@ win_symlink(PyObject *self, PyObject *args, PyObject *kwargs)
int target_is_directory = 0; int target_is_directory = 0;
DWORD res; DWORD res;
WIN32_FILE_ATTRIBUTE_DATA src_info; WIN32_FILE_ATTRIBUTE_DATA src_info;
if (!check_CreateSymbolicLinkW()) if (!check_CreateSymbolicLinkW())
{ {
/* raise NotImplementedError */ /* raise NotImplementedError */
...@@ -5352,7 +5352,7 @@ win_symlink(PyObject *self, PyObject *args, PyObject *kwargs) ...@@ -5352,7 +5352,7 @@ win_symlink(PyObject *self, PyObject *args, PyObject *kwargs)
Py_DECREF(src); Py_DECREF(src);
return NULL; return NULL;
} }
/* if src is a directory, ensure target_is_directory==1 */ /* if src is a directory, ensure target_is_directory==1 */
if( if(
GetFileAttributesExW( GetFileAttributesExW(
...@@ -5375,7 +5375,7 @@ win_symlink(PyObject *self, PyObject *args, PyObject *kwargs) ...@@ -5375,7 +5375,7 @@ win_symlink(PyObject *self, PyObject *args, PyObject *kwargs)
{ {
return win32_error_unicode("symlink", PyUnicode_AsUnicode(src)); return win32_error_unicode("symlink", PyUnicode_AsUnicode(src));
} }
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
...@@ -5573,7 +5573,7 @@ posix_open(PyObject *self, PyObject *args) ...@@ -5573,7 +5573,7 @@ posix_open(PyObject *self, PyObject *args)
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
PyUnicodeObject *po; PyUnicodeObject *po;
if (PyArg_ParseTuple(args, "Ui|i:mkdir", &po, &flag, &mode)) { if (PyArg_ParseTuple(args, "Ui|i:open", &po, &flag, &mode)) {
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
/* PyUnicode_AS_UNICODE OK without thread /* PyUnicode_AS_UNICODE OK without thread
lock as it is a simple dereference. */ lock as it is a simple dereference. */
...@@ -5588,7 +5588,7 @@ posix_open(PyObject *self, PyObject *args) ...@@ -5588,7 +5588,7 @@ posix_open(PyObject *self, PyObject *args)
PyErr_Clear(); PyErr_Clear();
#endif #endif
if (!PyArg_ParseTuple(args, "O&i|i", if (!PyArg_ParseTuple(args, "O&i|i:open",
PyUnicode_FSConverter, &ofile, PyUnicode_FSConverter, &ofile,
&flag, &mode)) &flag, &mode))
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment