[issue22945] Ctypes inconsistent between Linux and OS X

2014-12-16 Thread Daniel Standage

Daniel Standage added the comment:

Sorry for my radio silence. Your example was very helpful, and restores the 
behavior I was looking for. Thanks!

--
resolution:  - works for me
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22945
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22945] Ctypes inconsistent between Linux and OS X

2014-12-15 Thread Ned Deily

Ned Deily added the comment:

Thanks, eryksun.  Any objections to closing this issue?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22945
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22945] Ctypes inconsistent between Linux and OS X

2014-11-26 Thread eryksun

eryksun added the comment:

c_void_p's getfunc returns the address as an integer. In turn, an integer 
argument gets converted to a C int. This mean you need to a create a new 
c_void_p from the address for _as_parameter_, e.g.

self._as_parameter_ = c_void_p(self.g)

Or set restype to a subclass of c_void_p. ctypes won't call the getfunc in this 
case, e.g. 

class my_void_p(c_void_p):
pass

mylib.my_gizmo_create.restype = my_void_p

ConvParam
https://hg.python.org/cpython/file/ee879c0ffa11/Modules/_ctypes/callproc.c#l613

GetResult
https://hg.python.org/cpython/file/ee879c0ffa11/Modules/_ctypes/callproc.c#l903

--
nosy: +eryksun

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22945
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22945] Ctypes inconsistent between Linux and OS X

2014-11-25 Thread Daniel Standage

Changes by Daniel Standage daniel.stand...@gmail.com:


--
hgrepos:  -281

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22945
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22945] Ctypes inconsistent between Linux and OS X

2014-11-25 Thread Daniel Standage

New submission from Daniel Standage:

The ctypes documentation describes the '._as_parameter_' attribute, which 
simplifies using Python objects to encapsulate C objects. If a ctypes object 
with the '._as_parameter_' attribute defined is passed as a parameter to a C 
function, the value of '._as_parameter_' is supplied to the C function instead 
of a pointer to the Python project.

At least that's how it's advertised to work. And it does indeed work as 
advertised on Linux, but on Mac OS X the mechanism doesn't appear to work 
correctly. I have created a small dummy example demonstrating this at 
https://github.com/standage/ctypes-demo.

--
components: ctypes
hgrepos: 281
messages: 231692
nosy: Daniel.Standage
priority: normal
severity: normal
status: open
title: Ctypes inconsistent between Linux and OS X
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22945
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22945] Ctypes inconsistent between Linux and OS X

2014-11-25 Thread Ned Deily

Ned Deily added the comment:

FWIW, your test does seem to run if the C test program is instead built in 
32-bit mode (modifying CFLAGS to include -arch i386). For example, with the 
Apple OS X 10.10 system Python:

DYLD_LIBRARY_PATH=.. arch -i386 /usr/bin/python2.7 test.py
Gizmo 1: 15
Gizmo 2: 20
Empty data

--
nosy: +amaury.forgeotdarc, belopolsky, meador.inge, ned.deily

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22945
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com