[New-bugs-announce] [issue9884] The 4th parameter of method always None or 0 on x64 Windows.

Owen report at bugs.python.org
Fri Sep 17 11:12:22 CEST 2010


New submission from Owen <j2.nete at gmail.com>:

OS: Windows 2003STD x64 en

I have try to call python method from c++ dll by "WINFUNCTYPE".
But the 4th parameter is always None or 0 if the type is int or void* (float is works fine).

Following is the part of source code:
==code==========================================
import sys
from ctypes import *

windll.LoadLibrary("testPy2.dll")
#########################################

def test3(param1,param2,param3,param4,param5,param6,param7,param8,param9,param10):
  print("================")
  print(param1)
  print(param2)
  print(param3)
  # the 4th param4 is always 0.
  print(param4)
  print(param5)
  print(param6)
  print(param7)
  print(param8)
  print(param9)
  print(param10)
  print("================")
  return 20
  
C_METHOD_TYPE4 = WINFUNCTYPE(c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32)

windll.testPy2.fntestPy7(9,C_METHOD_TYPE4(test3))
==code==========================================

To my knowledge, both visual c++ and gcc use registers for the first few parameters, and then after that use the stack.  Maybe this is the reason.

I have attached some simple codes for reproduce this issue.
issues
  - testPy2      <- source code of the dll
  - test.py      <- python file to reproduce the issue
  - testPy2.dll  <- the dll to reproduce the issue

----------
components: Windows
files: issues.zip
messages: 116649
nosy: J2.NETe
priority: normal
severity: normal
status: open
title: The 4th parameter of method always None or 0 on x64 Windows.
versions: Python 2.7, Python 3.1
Added file: http://bugs.python.org/file18907/issues.zip

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9884>
_______________________________________


More information about the New-bugs-announce mailing list