exception message passed from Python to .NET correctly#84
exception message passed from Python to .NET correctly#84den-run-ai wants to merge 1 commit intopythonnet:masterfrom den-run-ai:master
Conversation
|
Hi, you need to be careful with reference counting when creating Python objects like this. Here you've created a new Python string object (_PyValueStr) but its reference count doesn't get decremented and so that object will never be deallocated. If you use the PyObject .net class instead, in a using block, that will ensure it gets cleaned up correctly - for example the following should solve your problem without leaking any objects The ToString method on PyObject does the string conversion, whereas Runtime.GetManagedString will only return a string of the Python object is a Python string. Could be worth adding a unit test too, since now we have CI builds set up for most of the supported configurations. cheers, |
|
Is this where the unit test is going to? https://github.com/pythonnet/pythonnet/blob/master/src/tests/test_exceptions.py |
|
Hi, yes that seems like a good place to put it, cheers, |
|
This has been implemented in #88, so I think this one can be closed now. Please feel free to re-open if there's still an issue. thanks! |
|
Did the unit test get implemented too? |
|
Nope :( If you have one left over from your earlier work please feel free to open another PR. thanks, |
#82