mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Re-flow several long lines from #1578269.
This commit is contained in:
parent
c739569be0
commit
74e4561a3c
6 changed files with 41 additions and 22 deletions
|
@ -12,7 +12,8 @@ from ctypes import wintypes
|
||||||
GetCurrentProcess = ctypes.windll.kernel32.GetCurrentProcess
|
GetCurrentProcess = ctypes.windll.kernel32.GetCurrentProcess
|
||||||
GetCurrentProcess.restype = wintypes.HANDLE
|
GetCurrentProcess.restype = wintypes.HANDLE
|
||||||
OpenProcessToken = ctypes.windll.advapi32.OpenProcessToken
|
OpenProcessToken = ctypes.windll.advapi32.OpenProcessToken
|
||||||
OpenProcessToken.argtypes = (wintypes.HANDLE, wintypes.DWORD, ctypes.POINTER(wintypes.HANDLE))
|
OpenProcessToken.argtypes = (wintypes.HANDLE, wintypes.DWORD,
|
||||||
|
ctypes.POINTER(wintypes.HANDLE))
|
||||||
OpenProcessToken.restype = wintypes.BOOL
|
OpenProcessToken.restype = wintypes.BOOL
|
||||||
|
|
||||||
class LUID(ctypes.Structure):
|
class LUID(ctypes.Structure):
|
||||||
|
@ -91,7 +92,8 @@ class TOKEN_PRIVILEGES(ctypes.Structure):
|
||||||
|
|
||||||
def get_array(self):
|
def get_array(self):
|
||||||
array_type = LUID_AND_ATTRIBUTES*self.count
|
array_type = LUID_AND_ATTRIBUTES*self.count
|
||||||
privileges = ctypes.cast(self.privileges, ctypes.POINTER(array_type)).contents
|
privileges = ctypes.cast(self.privileges,
|
||||||
|
ctypes.POINTER(array_type)).contents
|
||||||
return privileges
|
return privileges
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
|
@ -133,7 +135,8 @@ def get_process_token():
|
||||||
def get_symlink_luid():
|
def get_symlink_luid():
|
||||||
"Get the LUID for the SeCreateSymbolicLinkPrivilege"
|
"Get the LUID for the SeCreateSymbolicLinkPrivilege"
|
||||||
symlink_luid = LUID()
|
symlink_luid = LUID()
|
||||||
res = LookupPrivilegeValue(None, "SeCreateSymbolicLinkPrivilege", symlink_luid)
|
res = LookupPrivilegeValue(None, "SeCreateSymbolicLinkPrivilege",
|
||||||
|
symlink_luid)
|
||||||
if not res > 0:
|
if not res > 0:
|
||||||
raise RuntimeError("Couldn't lookup privilege value")
|
raise RuntimeError("Couldn't lookup privilege value")
|
||||||
return symlink_luid
|
return symlink_luid
|
||||||
|
|
|
@ -1034,7 +1034,8 @@ class Win32KillTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
def skipUnlessWindows6(test):
|
def skipUnlessWindows6(test):
|
||||||
if hasattr(sys, 'getwindowsversion') and sys.getwindowsversion().major >= 6:
|
if (hasattr(sys, 'getwindowsversion')
|
||||||
|
and sys.getwindowsversion().major >= 6):
|
||||||
return test
|
return test
|
||||||
return unittest.skip("Requires Windows Vista or later")(test)
|
return unittest.skip("Requires Windows Vista or later")(test)
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ class PlatformTest(unittest.TestCase):
|
||||||
# On Windows, the EXE needs to know where pythonXY.dll is at so we have
|
# On Windows, the EXE needs to know where pythonXY.dll is at so we have
|
||||||
# to add the directory to the path.
|
# to add the directory to the path.
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
os.environ["Path"] = "{};{}".format(os.path.dirname(sys.executable),
|
os.environ["Path"] = "{};{}".format(
|
||||||
os.environ["Path"])
|
os.path.dirname(sys.executable), os.environ["Path"])
|
||||||
|
|
||||||
def get(python):
|
def get(python):
|
||||||
cmd = [python, '-c',
|
cmd = [python, '-c',
|
||||||
|
|
|
@ -244,8 +244,8 @@ class TestSysConfig(unittest.TestCase):
|
||||||
# On Windows, the EXE needs to know where pythonXY.dll is at so we have
|
# On Windows, the EXE needs to know where pythonXY.dll is at so we have
|
||||||
# to add the directory to the path.
|
# to add the directory to the path.
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
os.environ["Path"] = "{};{}".format(os.path.dirname(sys.executable),
|
os.environ["Path"] = "{};{}".format(
|
||||||
os.environ["Path"])
|
os.path.dirname(sys.executable), os.environ["Path"])
|
||||||
|
|
||||||
# Issue 7880
|
# Issue 7880
|
||||||
def get(python):
|
def get(python):
|
||||||
|
|
|
@ -291,7 +291,8 @@ class MiscReadTest(CommonReadTest):
|
||||||
self.assertTrue(self.tar.getmembers()[-1].name == "misc/eof",
|
self.assertTrue(self.tar.getmembers()[-1].name == "misc/eof",
|
||||||
"could not find all members")
|
"could not find all members")
|
||||||
|
|
||||||
@unittest.skipUnless(hasattr(os, "link"), "Missing hardlink implementation")
|
@unittest.skipUnless(hasattr(os, "link"),
|
||||||
|
"Missing hardlink implementation")
|
||||||
@support.skip_unless_symlink
|
@support.skip_unless_symlink
|
||||||
def test_extract_hardlink(self):
|
def test_extract_hardlink(self):
|
||||||
# Test hardlink extraction (e.g. bug #857297).
|
# Test hardlink extraction (e.g. bug #857297).
|
||||||
|
@ -1423,11 +1424,13 @@ class LinkEmulationTest(ReadTest):
|
||||||
def test_hardlink_extraction2(self):
|
def test_hardlink_extraction2(self):
|
||||||
self._test_link_extraction("./ustar/linktest2/lnktype")
|
self._test_link_extraction("./ustar/linktest2/lnktype")
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(os, "symlink"), "Skip emulation if symlink exists")
|
@unittest.skipIf(hasattr(os, "symlink"),
|
||||||
|
"Skip emulation if symlink exists")
|
||||||
def test_symlink_extraction1(self):
|
def test_symlink_extraction1(self):
|
||||||
self._test_link_extraction("ustar/symtype")
|
self._test_link_extraction("ustar/symtype")
|
||||||
|
|
||||||
@unittest.skipIf(hasattr(os, "symlink"), "Skip emulation if symlink exists")
|
@unittest.skipIf(hasattr(os, "symlink"),
|
||||||
|
"Skip emulation if symlink exists")
|
||||||
def test_symlink_extraction2(self):
|
def test_symlink_extraction2(self):
|
||||||
self._test_link_extraction("./ustar/linktest2/symtype")
|
self._test_link_extraction("./ustar/linktest2/symtype")
|
||||||
|
|
||||||
|
|
|
@ -1117,7 +1117,8 @@ check_GetFinalPathNameByHandle()
|
||||||
"GetFinalPathNameByHandleA");
|
"GetFinalPathNameByHandleA");
|
||||||
*(FARPROC*)&Py_GetFinalPathNameByHandleW = GetProcAddress(hKernel32,
|
*(FARPROC*)&Py_GetFinalPathNameByHandleW = GetProcAddress(hKernel32,
|
||||||
"GetFinalPathNameByHandleW");
|
"GetFinalPathNameByHandleW");
|
||||||
has_GetFinalPathNameByHandle = Py_GetFinalPathNameByHandleA && Py_GetFinalPathNameByHandleW;
|
has_GetFinalPathNameByHandle = Py_GetFinalPathNameByHandleA &&
|
||||||
|
Py_GetFinalPathNameByHandleW;
|
||||||
}
|
}
|
||||||
return has_GetFinalPathNameByHandle;
|
return has_GetFinalPathNameByHandle;
|
||||||
}
|
}
|
||||||
|
@ -1310,9 +1311,12 @@ win32_fstat(int file_number, struct win32_stat *result)
|
||||||
/* similar to stat() */
|
/* similar to stat() */
|
||||||
result->st_mode = attributes_to_mode(info.dwFileAttributes);
|
result->st_mode = attributes_to_mode(info.dwFileAttributes);
|
||||||
result->st_size = (((__int64)info.nFileSizeHigh)<<32) + info.nFileSizeLow;
|
result->st_size = (((__int64)info.nFileSizeHigh)<<32) + info.nFileSizeLow;
|
||||||
FILE_TIME_to_time_t_nsec(&info.ftCreationTime, &result->st_ctime, &result->st_ctime_nsec);
|
FILE_TIME_to_time_t_nsec(&info.ftCreationTime, &result->st_ctime,
|
||||||
FILE_TIME_to_time_t_nsec(&info.ftLastWriteTime, &result->st_mtime, &result->st_mtime_nsec);
|
&result->st_ctime_nsec);
|
||||||
FILE_TIME_to_time_t_nsec(&info.ftLastAccessTime, &result->st_atime, &result->st_atime_nsec);
|
FILE_TIME_to_time_t_nsec(&info.ftLastWriteTime, &result->st_mtime,
|
||||||
|
&result->st_mtime_nsec);
|
||||||
|
FILE_TIME_to_time_t_nsec(&info.ftLastAccessTime, &result->st_atime,
|
||||||
|
&result->st_atime_nsec);
|
||||||
/* specific to fstat() */
|
/* specific to fstat() */
|
||||||
result->st_nlink = info.nNumberOfLinks;
|
result->st_nlink = info.nNumberOfLinks;
|
||||||
result->st_ino = (((__int64)info.nFileIndexHigh)<<32) + info.nFileIndexLow;
|
result->st_ino = (((__int64)info.nFileIndexHigh)<<32) + info.nFileIndexLow;
|
||||||
|
@ -2691,7 +2695,8 @@ posix__getfinalpathname(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
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, "Could not get a handle to file.");
|
return PyErr_Format(PyExc_RuntimeError,
|
||||||
|
"Could not get a handle to file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We have a good handle to the target, use it to determine the
|
/* We have a good handle to the target, use it to determine the
|
||||||
|
@ -3005,7 +3010,8 @@ static PyObject *
|
||||||
posix_unlink(PyObject *self, PyObject *args)
|
posix_unlink(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
return win32_1str(args, "remove", "y:remove", DeleteFileA, "U:remove", Py_DeleteFileW);
|
return win32_1str(args, "remove", "y:remove", DeleteFileA,
|
||||||
|
"U:remove", Py_DeleteFileW);
|
||||||
#else
|
#else
|
||||||
return posix_1str(args, "O&:remove", unlink);
|
return posix_1str(args, "O&:remove", unlink);
|
||||||
#endif
|
#endif
|
||||||
|
@ -4959,7 +4965,8 @@ typedef struct _REPARSE_DATA_BUFFER {
|
||||||
};
|
};
|
||||||
} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
|
} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
|
||||||
|
|
||||||
#define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
|
#define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER,\
|
||||||
|
GenericReparseBuffer)
|
||||||
|
|
||||||
#define MAXIMUM_REPARSE_DATA_BUFFER_SIZE ( 16 * 1024 )
|
#define MAXIMUM_REPARSE_DATA_BUFFER_SIZE ( 16 * 1024 )
|
||||||
|
|
||||||
|
@ -5023,8 +5030,11 @@ win_readlink(PyObject *self, PyObject *args)
|
||||||
"not a symbolic link");
|
"not a symbolic link");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
print_name = rdb->SymbolicLinkReparseBuffer.PathBuffer + rdb->SymbolicLinkReparseBuffer.PrintNameOffset;
|
print_name = rdb->SymbolicLinkReparseBuffer.PathBuffer +
|
||||||
result = PyUnicode_FromWideChar(print_name, rdb->SymbolicLinkReparseBuffer.PrintNameLength/2);
|
rdb->SymbolicLinkReparseBuffer.PrintNameOffset;
|
||||||
|
|
||||||
|
result = PyUnicode_FromWideChar(print_name,
|
||||||
|
rdb->SymbolicLinkReparseBuffer.PrintNameLength/2);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5043,7 +5053,8 @@ check_CreateSymbolicLinkW()
|
||||||
if (has_CreateSymbolicLinkW)
|
if (has_CreateSymbolicLinkW)
|
||||||
return has_CreateSymbolicLinkW;
|
return has_CreateSymbolicLinkW;
|
||||||
hKernel32 = GetModuleHandle("KERNEL32");
|
hKernel32 = GetModuleHandle("KERNEL32");
|
||||||
*(FARPROC*)&Py_CreateSymbolicLinkW = GetProcAddress(hKernel32, "CreateSymbolicLinkW");
|
*(FARPROC*)&Py_CreateSymbolicLinkW = GetProcAddress(hKernel32,
|
||||||
|
"CreateSymbolicLinkW");
|
||||||
if (Py_CreateSymbolicLinkW)
|
if (Py_CreateSymbolicLinkW)
|
||||||
has_CreateSymbolicLinkW = 1;
|
has_CreateSymbolicLinkW = 1;
|
||||||
return has_CreateSymbolicLinkW;
|
return has_CreateSymbolicLinkW;
|
||||||
|
@ -7586,7 +7597,8 @@ static PyMethodDef posix_methods[] = {
|
||||||
{"symlink", posix_symlink, METH_VARARGS, posix_symlink__doc__},
|
{"symlink", posix_symlink, METH_VARARGS, posix_symlink__doc__},
|
||||||
#endif /* HAVE_SYMLINK */
|
#endif /* HAVE_SYMLINK */
|
||||||
#if !defined(HAVE_SYMLINK) && defined(MS_WINDOWS)
|
#if !defined(HAVE_SYMLINK) && defined(MS_WINDOWS)
|
||||||
{"symlink", (PyCFunction)win_symlink, METH_VARARGS | METH_KEYWORDS, win_symlink__doc__},
|
{"symlink", (PyCFunction)win_symlink, METH_VARARGS | METH_KEYWORDS,
|
||||||
|
win_symlink__doc__},
|
||||||
#endif /* !defined(HAVE_SYMLINK) && defined(MS_WINDOWS) */
|
#endif /* !defined(HAVE_SYMLINK) && defined(MS_WINDOWS) */
|
||||||
#ifdef HAVE_SYSTEM
|
#ifdef HAVE_SYSTEM
|
||||||
{"system", posix_system, METH_VARARGS, posix_system__doc__},
|
{"system", posix_system, METH_VARARGS, posix_system__doc__},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue