I have some IronPython code that is creating a Mutex using the following constructor:
public Mutex( bool initiallyOwned, string name, out bool createdNew )
Since the last parameter is an out parameter you do not pass it to the method and instead it becomes an extra return value like this:
mutex, sucess = Mutex(True, 'some_mutex')
When this code runs it throws a TypeError saying that the Mutex object is not iterable. Since it is only returning one value this leads me to believe that IronPython is not choosing the correct overload. The Ironpython documentation says that you can control the exact overload that gets called by using the Overloads method on method objects.
The following bit of code attempts that, however, I get a ValueError stating that the index was out of range:
new_mutex = Mutex.__new__.Overloads[type(True), String, type(True)]
mutex, sucess = new_mutex(Mutex, True, 'some_mutex')
If I try using the Overloads attribute to force using a different overload it executes correctly. Anyone know where I’m going wrong?
You could explicitly pass the
out boolto the constructor like this:That lets the overload resolution stuff just do its thing.
I’m not quite sure how to extract the right method from
__new__.Overloads, but there has to be a way. If I just sayMutex.__new__.Overloads, it shows me a list that includes the overload that you’re looking for.