root icon indicating copy to clipboard operation
root copied to clipboard

cppyy update changed behavior of exceptions thrown in c++ and caught in python

Open tmadlener opened this issue 1 year ago • 1 comments

Check duplicate issues.

  • [X] Checked for duplicates

Description

This is effectively a duplicate of https://github.com/wlav/cppyy/issues/230. I am reporting it here mainly because this is also a behavioral change for ROOT, and I am not entirely sure whether it was introduced as part of the larger cppyy update or later (in which case it could maybe be fixed).

Reproducer

import ROOT

ROOT.gInterpreter.LoadText(
    """
class Foo {
  public:
    void bar() { throw std::logic_error("This is fine"); }
    void bar() const { throw std::logic_error("This is fine"); }
};
"""
)
foo = ROOT.Foo()
try:
    foo.bar()
except ROOT.std.logic_error:
    print("Caught")
    pass

ROOT version

The above worked up to root 6.30.06 and still works with the root version one gets when using a dev4 release. It doesn't work with a dev3 release at the moment.

Installation method

various (spack, LCG releases)

Operating system

various (verified on Ubuntu 22)

Additional context

No response

tmadlener avatar Apr 29 '24 11:04 tmadlener

I am not sure how easy it is to pick this up, but @wlav seems to have been able to fix this with this commit: https://github.com/wlav/CPyCppyy/commit/02072bbd818501364b37c133364e02976af4cc10

tmadlener avatar May 08 '24 13:05 tmadlener

Hi @tmadlener, yes that's very easy! I opened a PR. Thanks for pointing it out.

guitargeek avatar May 11 '24 11:05 guitargeek

Fixed in "not applicable" because no release was affected by this.

guitargeek avatar May 19 '24 18:05 guitargeek