# HG changeset patch # Parent dfcb64f51f7b4b8e037f80e2592ac4aa0155108a diff -r dfcb64f51f7b Include/longobject.h --- a/Include/longobject.h Wed Jun 05 12:20:24 2013 +0200 +++ b/Include/longobject.h Wed Jun 05 16:23:00 2013 +0100 @@ -52,6 +52,19 @@ #error "sizeof(pid_t) is neither sizeof(int), sizeof(long) or sizeof(long long)" #endif /* SIZEOF_PID_T */ +#if SIZEOF_VOID_P == SIZEOF_INT +# define _Py_PARSE_INTPTR "i" +# define _Py_PARSE_UINTPTR "I" +#elif SIZEOF_VOID_P == SIZEOF_LONG +# define _Py_PARSE_INTPTR "l" +# define _Py_PARSE_UINTPTR "k" +#elif defined(SIZEOF_LONG_LONG) && SIZEOF_VOID_P == SIZEOF_LONG_LONG +# define _Py_PARSE_INTPTR "L" +# define _Py_PARSE_UINTPTR "K" +#else +# error "void* different in size from int, long and long long" +#endif /* SIZEOF_VOID_P */ + /* Used by Python/mystrtoul.c. */ #ifndef Py_LIMITED_API PyAPI_DATA(unsigned char) _PyLong_DigitValue[256]; diff -r dfcb64f51f7b Misc/NEWS --- a/Misc/NEWS Wed Jun 05 12:20:24 2013 +0200 +++ b/Misc/NEWS Wed Jun 05 16:23:00 2013 +0100 @@ -10,9 +10,8 @@ Core and Builtins ----------------- -- Issue #17931: Fix PyLong_FromPid() on Windows 64-bit: processes are - identified by their HANDLE which is a pointer (and not a long, which is - smaller). +- Issue #17931: Resolve confusion on Windows between pids and process + handles. - Tweak the exception message when the magic number or size value in a bytecode file is truncated. diff -r dfcb64f51f7b Modules/posixmodule.c --- a/Modules/posixmodule.c Wed Jun 05 12:20:24 2013 +0200 +++ b/Modules/posixmodule.c Wed Jun 05 16:23:00 2013 +0100 @@ -5014,11 +5014,7 @@ if (spawnval == -1) return posix_error(); else -#if SIZEOF_LONG == SIZEOF_VOID_P - return Py_BuildValue("l", (long) spawnval); -#else - return Py_BuildValue("L", (PY_LONG_LONG) spawnval); -#endif + return Py_BuildValue(_Py_PARSE_INTPTR, spawnval); } @@ -5104,11 +5100,7 @@ if (spawnval == -1) (void) posix_error(); else -#if SIZEOF_LONG == SIZEOF_VOID_P - res = Py_BuildValue("l", (long) spawnval); -#else - res = Py_BuildValue("L", (PY_LONG_LONG) spawnval); -#endif + res = Py_BuildValue(_Py_PARSE_INTPTR, spawnval); while (--envc >= 0) PyMem_DEL(envlist[envc]); @@ -6603,7 +6595,7 @@ Py_intptr_t pid; int status, options; - if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:waitpid", &pid, &options)) + if (!PyArg_ParseTuple(args, _Py_PARSE_INTPTR "i:waitpid", &pid, &options)) return NULL; Py_BEGIN_ALLOW_THREADS pid = _cwait(&status, pid, options); @@ -6612,7 +6604,7 @@ return posix_error(); /* shift the status left a byte so this is more like the POSIX waitpid */ - return Py_BuildValue("Ni", PyLong_FromPid(pid), status << 8); + return Py_BuildValue(_Py_PARSE_INTPTR "i", pid, status << 8); } #endif /* HAVE_WAITPID || HAVE_CWAIT */ diff -r dfcb64f51f7b PC/msvcrtmodule.c --- a/PC/msvcrtmodule.c Wed Jun 05 12:20:24 2013 +0200 +++ b/PC/msvcrtmodule.c Wed Jun 05 16:23:00 2013 +0100 @@ -113,11 +113,12 @@ static PyObject * msvcrt_open_osfhandle(PyObject *self, PyObject *args) { - long handle; + Py_intptr_t handle; int flags; int fd; - if (!PyArg_ParseTuple(args, "li:open_osfhandle", &handle, &flags)) + if (!PyArg_ParseTuple(args, _Py_PARSE_INTPTR "i:open_osfhandle", + &handle, &flags)) return NULL; fd = _open_osfhandle(handle, flags); diff -r dfcb64f51f7b PC/pyconfig.h --- a/PC/pyconfig.h Wed Jun 05 12:20:24 2013 +0200 +++ b/PC/pyconfig.h Wed Jun 05 16:23:00 2013 +0100 @@ -723,9 +723,6 @@ /* The size of `wchar_t', as computed by sizeof. */ #define SIZEOF_WCHAR_T 2 -/* The size of `pid_t' (HANDLE). */ -#define SIZEOF_PID_T SIZEOF_VOID_P - /* Define if you have the dl library (-ldl). */ /* #undef HAVE_LIBDL */