wlav / cppyy

Other
412 stars 42 forks source link

Add regression test for heuristic memory policy #244

Closed guitargeek closed 5 months ago

guitargeek commented 5 months 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 5 months 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 5 months 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 5 months ago

Code now returns the old policy.

guitargeek commented 5 months ago

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