wlav / cppyy

Other
384 stars 38 forks source link

Add regression test for heuristic memory policy #244

Closed guitargeek closed 1 week ago

guitargeek commented 4 weeks ago

Regression test covering the problem reported in #221.

The regression was that the caller gave up ownership also in the case of const ptr, which is not the original behavior of cppyy, i.e. the behavior that ROOT came to expect.

The fix that makes this test pass is provided in this PR: https://github.com/wlav/CPyCppyy/pull/22

wlav commented 4 weeks ago

This test should restore the old global policy (returned by SetMemoryPolicy) or it risks messing up other tests. Furthermore, the whole test should be in a try/except/finally with that restore in the finally to make sure it is always run, even if the test fails.

guitargeek commented 1 week ago

The SetMemoryPolicy just returns None, not the old policy: https://github.com/wlav/CPyCppyy/blob/master/src/CPyCppyyModule.cxx#L882

Is there another way to get it?

wlav commented 1 week ago

Code now returns the old policy.

guitargeek commented 1 week ago

Thanks a lot @wlav! I have updated the test as you suggested.