Skip to content Skip to sidebar Skip to footer

Ironpython: Function Works In CPython, Mysterious Null Pointer Exception In IronPython

I'm trying to do something that seems very simple, and falls within the range of standard python. The following function takes a collection of sets, and returns all of the items th

Solution 1:

It's a bug. It will be fixed in 2.7.1, but I don't think the fix is in the 2.7.1 Beta 1 release.


Solution 2:

This is a bug still present in the 2.7.1 Beta 1 release.

It has been fixed in master, and the fix will be included in the next release.

IronPython 3.0 (3.0.0.0) on .NET 4.0.30319.235
Type "help", "copyright", "credits" or "license" for more information.
>>> import copy
>>>
>>> def cross_intersections(sets):
...     in_two = set()
...     sets_copy = copy.copy(sets)
...     while sets_copy:
...         comp = sets_copy.pop()
...         for each in sets_copy:
...             new = comp & each
...             print new,     # Print statements to show that these references exist
...             print in_two
...             in_two |= new  # This is where the error occurs in IronPython
...     return in_two
...
>>>
>>> a = set([1,2,3,4])
>>> b = set([3,4,5,6])
>>> c = set([2,4,6,8])
>>>
>>> cross = cross_intersections([a,b,c])
set([2, 4]) set([])
set([4, 6]) set([2, 4])
set([3, 4]) set([2, 4, 6])

Post a Comment for "Ironpython: Function Works In CPython, Mysterious Null Pointer Exception In IronPython"