New submission from STINNER Victor:

The issue #1983 was not fixed on Windows: pid_t is HANDLE on Windows, which is 
a pointer. SIZEOF_PID_T is not defined in PC/pyconfig.h and so longobject.h 
takes the default implementation (use C long type):

/* Issue #1983: pid_t can be longer than a C long on some systems */
#if !defined(SIZEOF_PID_T) || SIZEOF_PID_T == SIZEOF_INT
#define _Py_PARSE_PID "i"
#define PyLong_FromPid PyLong_FromLong
#define PyLong_AsPid PyLong_AsLong
#elif SIZEOF_PID_T == SIZEOF_LONG
...

The consequence is a compiler warning:

..\Modules\posixmodule.c(6603): warning C4244: 'function' : conversion from 
'Py_intptr_t' to 'long', possible loss of data 
[C:\buildbot.python.org\3.x.kloth-win64\build\PCbuild\pythoncore.vcxproj]

It would be safer to define SIZEOF_PID_T on Windows:

#define SIZEOF_PID_T SIZEOF_VOID_P

I didn't test attached patch on Windows.

Python 3.2 is affected, but I don't think that the issue is important enough to 
touch this branch (which now only accept security fixes).

See also issue #17870.

----------
components: Windows
files: win_sizeof_pid_t.patch
keywords: patch
messages: 188688
nosy: haypo, serhiy.storchaka, tim.golden
priority: normal
severity: normal
status: open
title: PyLong_FromPid() is not correctly defined on Windows 64-bit
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file30170/win_sizeof_pid_t.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17931>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to