Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python class inherited from a ROOT class fails in last release #16520

Open
1 task
PPaye opened this issue Sep 25, 2024 · 1 comment
Open
1 task

Python class inherited from a ROOT class fails in last release #16520

PPaye opened this issue Sep 25, 2024 · 1 comment

Comments

@PPaye
Copy link
Contributor

PPaye commented Sep 25, 2024

Check duplicate issues.

  • Checked for duplicates

Description

Inherit whatever ROOT parent class in a python class generates error
on the TObject::DoError method.
Python raises an error on TypeError. Which is categorical wrong, it should be NotImplemented.

At the root-forum it is being suggested that RDataFrame is not a class to be inherited in PyRoot;
due to "composition over inheritance" idiom and warnings on bad data type manipulation internally
leading to wrong numerical results.
Is this going to be for all ROOT classes? No ROOT class should be inherited in a Python class from now on ?

It only affects the last release 6.32.04 and 6.32.06
Release 6.30.02 works fine.

Similar issues:
#12391
https://root-forum.cern.ch/t/rdataframe-has-no-virtual-destructor/53605
https://root-forum.cern.ch/t/typeerror-no-python-side-overrides-supported-failed-to-compile-the-dispatcher-code/53198/14

Reproducer

from ROOT import TObject

class C(TObject):
    def __init__(self):
        super().__init__()  # Initialize the base class

    def some_method(self):
        print("This is a method in class C.")
  In [1]: from ROOT import TObject
        ...: 
        ...: class C(TObject):
        ...:     def __init__(self):
        ...:         super().__init__()  # Call the constructor of TObject
        ...: 
Installed ROOT event loop hook.
input_line_35:10:62: error: unknown type name '__va_list_tag'
  void DoError(int arg0, const char* arg1, const char* arg2, __va_list_tag[1] arg3) const {
                                                             ^
input_line_35:10:79: error: expected ')'
  void DoError(int arg0, const char* arg1, const char* arg2, __va_list_tag[1] arg3) const {
                                                                              ^
input_line_35:10:15: note: to match this '('
  void DoError(int arg0, const char* arg1, const char* arg2, __va_list_tag[1] arg3) const {
              ^
input_line_35:11:47: error: use of undeclared identifier 'arg3'
    return TObject::DoError(arg0, arg1, arg2, arg3);
                                              ^
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[1], line 3
      1 from ROOT import TObject
----> 3 class C(TObject):
      4     def __init__(self):
      5         super().__init__()  # Call the constructor of TObject

TypeError: no python-side overrides supported (failed to compile the dispatcher code)

ROOT version

ROOT Version: 6.32.02
Built for linuxx8664gcc on Jun 18 2024, 04:46:14
From tags/v6-32-02@v6-32-02

ROOT Version: 6.32.06
Built for linuxx8664gcc on Sep 21 2024, 19:19:59
From tags/v6-32-06@v6-32-06

Installation method

pre-built binary

Operating system

Linux, Ubuntu 23

Additional context

No response

@vepadulano
Copy link
Member

Dear @PPaye ,

Thanks for reaching out to us! At a first glance, I would say this is a degradation and we should try to understand why that happened, generally speaking.

But please note the following:

At the root-forum it is being suggested that RDataFrame is not a class to be inherited in PyRoot;

The answer on the ROOT forum does not say that RDataFrame should not be inherited-from in a Python class. It should not be inherited-from in general. The class explicitly does not provide a virtual destructor, so virtual inheritance would not work even in C++. This is part of the class design and it is not related to this issue with Python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants