[Ironpython-users] ctypes module in version 2.7.2 can't create Union values

Bruce Bromberek bruce.bromberek at gmail.com
Fri Apr 20 22:46:53 CEST 2012


Looks like you are running 32bit python on a 64 bit OS

On 4/20/12, Slide <slide.o.mix at gmail.com> wrote:
> I am unable to reproduce this, I am also running Win7 x64
>
> Running with ipy64.exe
>
> IronPython 2.7.2.1 (2.7.0.40) on .NET 4.0.30319.261 (64-bit)
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from ctypes import *
>>>> class foo(Union):
> ...     __fields__ = [("t", c_uint), ("b", c_float)]
> ...
>>>> bar = foo()
>>>> bar.t = 1
>>>>
>
> Running with ipy.exe
>
> IronPython 2.7.2.1 (2.7.0.40) on .NET 4.0.30319.261 (32-bit)
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from ctypes import *
>>>> class foo(Union):
> ...     __fields__ = [("t", c_uint), ("b", c_float)]
> ...
>>>> bar = foo()
>>>> bar.t = 1
>>>>
>
>
> On Fri, Apr 20, 2012 at 6:45 AM,  <mva at sysfault.org> wrote:
>> Dear all,
>>
>> on a 64-bit Windows 7 machine (other platforms untested), I find myself
>> unable to create a
>> ctypes.Union-based class wrapper for a C type.
>> Regardless of what kind of Union I create, it always ends up with a
>> "object reference not set to an instance of an object" error from .NET.
>> Find
>> below a brief
>> command line example including the necessary .NET and IronPython
>> information.
>>
>> IronPython 2.7.2.1 (2.7.0.40) on .NET 4.0.30319.261 (32-bit)
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>>
>>>>> from ctypes import *
>>>>> class foo(Union):
>>
>> ...     _fields_ = [("t", c_uint), ("b", c_float)]
>> ...
>>>>>
>>>>> bar = foo()
>>>>> bar.t = 1
>>
>> Traceback (most recent call last):
>>  File "<stdin>", line 1, in <module>
>> SystemError: Object reference not set to an instance of an object.
>>
>> I'm not subscribed to this list, in case you require more information
>> please
>> keep me in CC.
>>
>> Regards
>> Marcus
>>
>> _______________________________________________
>> Ironpython-users mailing list
>> Ironpython-users at python.org
>> http://mail.python.org/mailman/listinfo/ironpython-users
>
>
>
> --
> Website: http://earl-of-code.com
> _______________________________________________
> Ironpython-users mailing list
> Ironpython-users at python.org
> http://mail.python.org/mailman/listinfo/ironpython-users
>

-- 
Sent from my mobile device


More information about the Ironpython-users mailing list