Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion bindings/pyroot/cppyy/CPyCppyy/src/TemplateProxy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ static PyObject* tpp_call(TemplateProxy* pytmpl, PyObject* args, PyObject* kwds)
if (result)
TPPCALL_RETURN;

// case 4: auto-instantiation from types of arguments
// case 4.1: auto-instantiation from types of arguments
for (auto pref : {Utility::kReference, Utility::kPointer, Utility::kValue}) {
// TODO: no need to loop if there are no non-instance arguments; also, should any
// failed lookup be removed?
Expand All @@ -671,6 +671,17 @@ static PyObject* tpp_call(TemplateProxy* pytmpl, PyObject* args, PyObject* kwds)
if (!pcnt) break; // preference never used; no point trying others
}

// case 4.2: auto-instantiation with zero template arguments (in case they have defaults)
std::string fullname = pytmpl->fTI->fCppName + "<>";
pymeth = pytmpl->Instantiate(fullname, args, nargsf, Utility::kNone);
if (pymeth) {
// attempt actual call; allow implicit conversion of arguments
result = CallMethodImp(pytmpl, pymeth, args, nargsf, kwds, true, sighash);
if (result)
TPPCALL_RETURN;
}
Utility::FetchError(errors);

// case 5: low priority methods, such as ones that take void* arguments
result = SelectAndForward(pytmpl, pytmpl->fTI->fLowPriority, args, nargsf, kwds,
false /* implicitOkay */, false /* use_targs */, sighash, errors);
Expand Down
20 changes: 20 additions & 0 deletions bindings/pyroot/cppyy/cppyy/test/test_regression.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os, sys, pytest

Check failure on line 1 in bindings/pyroot/cppyy/cppyy/test/test_regression.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E401)

bindings/pyroot/cppyy/cppyy/test/test_regression.py:1:1: E401 Multiple imports on one line
from pytest import mark, raises, skip
from support import setup_make, IS_WINDOWS, ispypy, IS_MAC, IS_MAC_ARM

Check failure on line 3 in bindings/pyroot/cppyy/cppyy/test/test_regression.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (F401)

bindings/pyroot/cppyy/cppyy/test/test_regression.py:3:21: F401 `support.setup_make` imported but unused

Check failure on line 3 in bindings/pyroot/cppyy/cppyy/test/test_regression.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (I001)

bindings/pyroot/cppyy/cppyy/test/test_regression.py:1:1: I001 Import block is un-sorted or un-formatted

Expand All @@ -7,7 +7,7 @@
helpout = []

def setup_class(cls):
import cppyy

Check failure on line 10 in bindings/pyroot/cppyy/cppyy/test/test_regression.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (F401)

bindings/pyroot/cppyy/cppyy/test/test_regression.py:10:16: F401 `cppyy` imported but unused

if sys.hexversion < 0x30d0000:
def stringpager(text, cls=cls):
Expand All @@ -22,7 +22,7 @@
def test01_kdcraw(self):
"""Doc strings for KDcrawIface (used to crash)."""

import cppyy, pydoc

Check failure on line 25 in bindings/pyroot/cppyy/cppyy/test/test_regression.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (I001)

bindings/pyroot/cppyy/cppyy/test/test_regression.py:25:9: I001 Import block is un-sorted or un-formatted

Check failure on line 25 in bindings/pyroot/cppyy/cppyy/test/test_regression.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E401)

bindings/pyroot/cppyy/cppyy/test/test_regression.py:25:9: E401 Multiple imports on one line

# TODO: run a find for these paths
qtpath = "/usr/include/qt5"
Expand Down Expand Up @@ -54,9 +54,9 @@
if ispypy:
skip('hangs (??) in pypy')

import cppyy, pydoc

Check failure on line 57 in bindings/pyroot/cppyy/cppyy/test/test_regression.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (I001)

bindings/pyroot/cppyy/cppyy/test/test_regression.py:57:9: I001 Import block is un-sorted or un-formatted

Check failure on line 57 in bindings/pyroot/cppyy/cppyy/test/test_regression.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E401)

bindings/pyroot/cppyy/cppyy/test/test_regression.py:57:9: E401 Multiple imports on one line

assert not '__abstractmethods__' in dir(cppyy.gbl.gInterpreter)

Check failure on line 59 in bindings/pyroot/cppyy/cppyy/test/test_regression.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E713)

bindings/pyroot/cppyy/cppyy/test/test_regression.py:59:20: E713 Test for membership should be `not in`
assert '__class__' in dir(cppyy.gbl.gInterpreter)

self.__class__.helpout = []
Expand All @@ -68,7 +68,7 @@

cppyy.cppdef("namespace cppyy_regression_test { void iii() {}; }")

assert not 'iii' in cppyy.gbl.cppyy_regression_test.__dict__

Check failure on line 71 in bindings/pyroot/cppyy/cppyy/test/test_regression.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E713)

bindings/pyroot/cppyy/cppyy/test/test_regression.py:71:20: E713 Test for membership should be `not in`
assert not '__abstractmethods__' in dir(cppyy.gbl.cppyy_regression_test)
assert '__class__' in dir(cppyy.gbl.cppyy_regression_test)
assert 'iii' in dir(cppyy.gbl.cppyy_regression_test)
Expand Down Expand Up @@ -1410,6 +1410,26 @@
assert out == ""
assert err == ""

def test48_variadic_conversion(self):
"""Conversion for a variadic template function"""

import cppyy
cppyy.cppdef("""\
namespace regression_test48 {
template <typename... Ts> void f(std::pair<double, double>) {}
class A {
public:
template <typename... Ts>
void m(std::pair<double, double>) {}
};
}""")

r48 = cppyy.gbl.regression_test48

r48.f((1, 1))
a = r48.A()
a.m((1, 1))

@mark.xfail(run=False, condition=IS_MAC_ARM or IS_WINDOWS == 64, reason="LLVM JIT fails to catch exceptions")
def test49_overloads_with_runtime_errors(self):
"""Regression test for https://github.com/root-project/root/issues/17497
Expand Down
Loading