Details
-
Type:
Bug
-
Status: Open (View Workflow)
-
Priority:
Blocker
-
Resolution: Unresolved
-
Affects Version/s: master
-
Fix Version/s: None
-
Component/s: PyROOT
-
Labels:None
-
Environment:
ROOT master@33007b74
Description
Hello,
This example, taken from the front page https://cppyy.readthedocs.io/en/latest/ gives an error on last line if cppyy under ROOT is used:
cppyy.cppdef(""" |
class MyClass { |
public: |
MyClass(int i) : m_data(i) {} |
virtual ~MyClass() {}
|
virtual int add_int(int i) { return m_data + i; } |
int m_data; |
};""") |
|
from cppyy.gbl import MyClass |
|
m = MyClass(42) |
|
cppyy.cppdef(""" |
void say_hello(MyClass* m) { |
std::cout << "Hello, the number is: " << m->m_data << std::endl; |
}""") |
|
|
MyClass.say_hello = cppyy.gbl.say_hello
|
m.say_hello()
|
m.m_data = 13 |
m.say_hello()
|
|
class PyMyClass(MyClass): |
def add_int(self, i): # python side override (CPython only)
|
return self.m_data + 2*i |
|
cppyy.cppdef("int callback(MyClass* m, int i) { return m->add_int(i); }") |
|
cppyy.gbl.callback(m, 2) |
cppyy.gbl.callback(PyMyClass(1), 2) |
---------------------------------------------------------------------------
|
TypeError Traceback (most recent call last)
|
<ipython-input-23-a22c5c531ce6> in <module> |
----> 1 cppyy.gbl.callback(PyMyClass(1), 2) |
|
TypeError: none of the 2 overloaded methods succeeded. Full details: |
no constructor available for 'MyClass' |
MyClass::MyClass(const MyClass&) => |
TypeError: could not convert argument 1 |
This example, however, works under standalone cppyy of the same version (1.6.2).
Similarly, this tutorial https://bitbucket.org/wlav/cppyy/src/master/doc/tutorial/CppyyTutorial.ipynb?viewer=nbviewer&fileviewer=notebook-viewer%3Anbviewer fails on In [10] if it is run under ROOT's cppyy:
--------------------------------------------------------------------------
|
TypeError Traceback (most recent call last)
|
<ipython-input-11-e5a39e3833ad> in <module> |
2 Integer2 = cppyy.gbl.Math.Integer2 # first time a new namespace is used, it can not be imported from |
3 v2 = vector[Integer2]() |
----> 4 v2 += [Integer2(j) for j in range(10)] |
5 |
6 # now test the effect of the pythonizor: |
|
<ipython-input-11-e5a39e3833ad> in <listcomp>(.0) |
2 Integer2 = cppyy.gbl.Math.Integer2 # first time a new namespace is used, it can not be imported from |
3 v2 = vector[Integer2]() |
----> 4 v2 += [Integer2(j) for j in range(10)] |
5 |
6 # now test the effect of the pythonizor: |
|
TypeError: none of the 3 overloaded methods succeeded. Full details: |
Integer2::Integer2(Math::Integer2&&) =>
|
TypeError: could not convert argument 1 |
Integer2::Integer2(const Math::Integer2&) => |
TypeError: could not convert argument 1 |
Integer2::Integer2() =>
|
TypeError: takes at most 0 arguments (1 given) |
The tutorial gives no error under standalone cppyy 1.6.2 (if ROOT is not installed).
Is cppyy under ROOT passing all cppyy's tests?
Cheers,
Jiri