| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 448f1a8 commit ac0ad88
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,6 +52,19 @@ PyAPI_FUNC(PyObject *) PyLong_GetInfo(void); | |||
| 52 | 52 | #error "sizeof(pid_t) is neither sizeof(int), sizeof(long) or sizeof(long long)" | |
| 53 | 53 | #endif /* SIZEOF_PID_T */ | |
| 54 | 54 | ||
| 55 | + #if SIZEOF_VOID_P == SIZEOF_INT | ||
| 56 | + # define _Py_PARSE_INTPTR "i" | ||
| 57 | + # define _Py_PARSE_UINTPTR "I" | ||
| 58 | + #elif SIZEOF_VOID_P == SIZEOF_LONG | ||
| 59 | + # define _Py_PARSE_INTPTR "l" | ||
| 60 | + # define _Py_PARSE_UINTPTR "k" | ||
| 61 | + #elif defined(SIZEOF_LONG_LONG) && SIZEOF_VOID_P == SIZEOF_LONG_LONG | ||
| 62 | + # define _Py_PARSE_INTPTR "L" | ||
| 63 | + # define _Py_PARSE_UINTPTR "K" | ||
| 64 | + #else | ||
| 65 | + # error "void* different in size from int, long and long long" | ||
| 66 | + #endif /* SIZEOF_VOID_P */ | ||
| 67 | + | ||
| 55 | 68 | /* Used by Python/mystrtoul.c. */ | |
| 56 | 69 | #ifndef Py_LIMITED_API | |
| 57 | 70 | PyAPI_DATA(unsigned char) _PyLong_DigitValue[256]; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,9 +10,8 @@ What's New in Python 3.4.0 Alpha 1? | |||
| 10 | 10 | Core and Builtins | |
| 11 | 11 | ----------------- | |
| 12 | 12 | ||
| 13 | - - Issue #17931: Fix PyLong_FromPid() on Windows 64-bit: processes are | ||
| 14 | - identified by their HANDLE which is a pointer (and not a long, which is | ||
| 15 | - smaller). | ||
| 13 | + - Issue #17931: Resolve confusion on Windows between pids and process | ||
| 14 | + handles. | ||
| 16 | 15 | ||
| 17 | 16 | - Tweak the exception message when the magic number or size value in a bytecode | |
| 18 | 17 | file is truncated. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5014,11 +5014,7 @@ posix_spawnv(PyObject *self, PyObject *args) | |||
| 5014 | 5014 | if (spawnval == -1) | |
| 5015 | 5015 | return posix_error(); | |
| 5016 | 5016 | else | |
| 5017 | - #if SIZEOF_LONG == SIZEOF_VOID_P | ||
| 5018 | - return Py_BuildValue("l", (long) spawnval); | ||
| 5019 | - #else | ||
| 5020 | - return Py_BuildValue("L", (PY_LONG_LONG) spawnval); | ||
| 5021 | - #endif | ||
| 5017 | + return Py_BuildValue(_Py_PARSE_INTPTR, spawnval); | ||
| 5022 | 5018 | } | |
| 5023 | 5019 | ||
| 5024 | 5020 | ||
@@ -5104,11 +5100,7 @@ posix_spawnve(PyObject *self, PyObject *args) | |||
| 5104 | 5100 | if (spawnval == -1) | |
| 5105 | 5101 | (void) posix_error(); | |
| 5106 | 5102 | else | |
| 5107 | - #if SIZEOF_LONG == SIZEOF_VOID_P | ||
| 5108 | - res = Py_BuildValue("l", (long) spawnval); | ||
| 5109 | - #else | ||
| 5110 | - res = Py_BuildValue("L", (PY_LONG_LONG) spawnval); | ||
| 5111 | - #endif | ||
| 5103 | + res = Py_BuildValue(_Py_PARSE_INTPTR, spawnval); | ||
| 5112 | 5104 | ||
| 5113 | 5105 | while (--envc >= 0) | |
| 5114 | 5106 | PyMem_DEL(envlist[envc]); | |
@@ -6178,16 +6170,17 @@ static PyObject * | |||
| 6178 | 6170 | win32_kill(PyObject *self, PyObject *args) | |
| 6179 | 6171 | { | |
| 6180 | 6172 | PyObject *result; | |
| 6181 | - DWORD pid, sig, err; | ||
| 6173 | + pid_t pid; | ||
| 6174 | + DWORD sig, err; | ||
| 6182 | 6175 | HANDLE handle; | |
| 6183 | 6176 | ||
| 6184 | - if (!PyArg_ParseTuple(args, "kk:kill", &pid, &sig)) | ||
| 6177 | + if (!PyArg_ParseTuple(args, _Py_PARSE_PID "k:kill", &pid, &sig)) | ||
| 6185 | 6178 | return NULL; | |
| 6186 | 6179 | ||
| 6187 | 6180 | /* Console processes which share a common console can be sent CTRL+C or | |
| 6188 | 6181 | CTRL+BREAK events, provided they handle said events. */ | |
| 6189 | 6182 | if (sig == CTRL_C_EVENT || sig == CTRL_BREAK_EVENT) { | |
| 6190 | - if (GenerateConsoleCtrlEvent(sig, pid) == 0) { | ||
| 6183 | + if (GenerateConsoleCtrlEvent(sig, (DWORD)pid) == 0) { | ||
| 6191 | 6184 | err = GetLastError(); | |
| 6192 | 6185 | PyErr_SetFromWindowsErr(err); | |
| 6193 | 6186 | } | |
@@ -6197,7 +6190,7 @@ win32_kill(PyObject *self, PyObject *args) | |||
| 6197 | 6190 | ||
| 6198 | 6191 | /* If the signal is outside of what GenerateConsoleCtrlEvent can use, | |
| 6199 | 6192 | attempt to open and terminate the process. */ | |
| 6200 | - handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid); | ||
| 6193 | + handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid); | ||
| 6201 | 6194 | if (handle == NULL) { | |
| 6202 | 6195 | err = GetLastError(); | |
| 6203 | 6196 | return PyErr_SetFromWindowsErr(err); | |
@@ -6603,7 +6596,7 @@ posix_waitpid(PyObject *self, PyObject *args) | |||
| 6603 | 6596 | Py_intptr_t pid; | |
| 6604 | 6597 | int status, options; | |
| 6605 | 6598 | ||
| 6606 | - if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:waitpid", &pid, &options)) | ||
| 6599 | + if (!PyArg_ParseTuple(args, _Py_PARSE_INTPTR "i:waitpid", &pid, &options)) | ||
| 6607 | 6600 | return NULL; | |
| 6608 | 6601 | Py_BEGIN_ALLOW_THREADS | |
| 6609 | 6602 | pid = _cwait(&status, pid, options); | |
@@ -6612,7 +6605,7 @@ posix_waitpid(PyObject *self, PyObject *args) | |||
| 6612 | 6605 | return posix_error(); | |
| 6613 | 6606 | ||
| 6614 | 6607 | /* shift the status left a byte so this is more like the POSIX waitpid */ | |
| 6615 | - return Py_BuildValue("Ni", PyLong_FromPid(pid), status << 8); | ||
| 6608 | + return Py_BuildValue(_Py_PARSE_INTPTR "i", pid, status << 8); | ||
| 6616 | 6609 | } | |
| 6617 | 6610 | #endif /* HAVE_WAITPID || HAVE_CWAIT */ | |
| 6618 | 6611 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -113,11 +113,12 @@ os.O_BINARY."); | |||
| 113 | 113 | static PyObject * | |
| 114 | 114 | msvcrt_open_osfhandle(PyObject *self, PyObject *args) | |
| 115 | 115 | { | |
| 116 | - long handle; | ||
| 116 | + Py_intptr_t handle; | ||
| 117 | 117 | int flags; | |
| 118 | 118 | int fd; | |
| 119 | 119 | ||
| 120 | - if (!PyArg_ParseTuple(args, "li:open_osfhandle", &handle, &flags)) | ||
| 120 | + if (!PyArg_ParseTuple(args, _Py_PARSE_INTPTR "i:open_osfhandle", | ||
| 121 | + &handle, &flags)) | ||
| 121 | 122 | return NULL; | |
| 122 | 123 | ||
| 123 | 124 | fd = _open_osfhandle(handle, flags); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -723,8 +723,8 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ | |||
| 723 | 723 | /* The size of `wchar_t', as computed by sizeof. */ | |
| 724 | 724 | #define SIZEOF_WCHAR_T 2 | |
| 725 | 725 | ||
| 726 | - /* The size of `pid_t' (HANDLE). */ | ||
| 727 | - #define SIZEOF_PID_T SIZEOF_VOID_P | ||
| 726 | + /* The size of `pid_t', as computed by sizeof. */ | ||
| 727 | + #define SIZEOF_PID_T SIZEOF_INT | ||
| 728 | 728 | ||
| 729 | 729 | /* Define if you have the dl library (-ldl). */ | |
| 730 | 730 | /* #undef HAVE_LIBDL */ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments