Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
54f2502
[cppinterop] Add Cling-specific RAII, lookup and dispatch patches [up…
aaronj0 Apr 23, 2026
9a38ec3
[cppinterop] Fix JitCall codegen for deleted copy ctor in args [upstr…
aaronj0 May 11, 2026
6116963
[cppinterop] Use canonical return type in wrapper codegen [upstream]
aaronj0 May 21, 2026
e6f290e
[cppyy-backend] Replace clingwrapper with compres forks [fork-baseline]
aaronj0 Apr 23, 2026
cf9b604
[cppyy-backend] Make GetActualClass robust across platforms
aaronj0 May 11, 2026
56817dd
[cppyy-backend] Pass CPPINTEROP_DIR directly to AddIncludePath [ROOT-…
aaronj0 May 19, 2026
2917c0a
[cppyy-backend] Apply ROOT patches on compres fork baseline [ROOT-patch]
aaronj0 Apr 23, 2026
4b22a21
[cppyy-backend] Stage CppInterOp headers via etc/cppinterop [ROOT-patch]
aaronj0 May 19, 2026
8d3ef91
[cppyy] Replace frontend with compres forks [fork-baseline]
aaronj0 Apr 24, 2026
3b6db56
[cppyy] Match basic_string names with and without default template ar…
aaronj0 Apr 30, 2026
3990032
[cppyy] Apply ROOT-specific patches [ROOT-patch]
aaronj0 Apr 24, 2026
fb04a37
[CPyCppyy] Replace with compres forks [fork-baseline]
aaronj0 Apr 23, 2026
3f787c2
[CPyCppyy] Refactor the global call-policy system into GlobalPolicyFl…
aaronj0 Apr 24, 2026
00fea1e
[CPyCppyy] Add converters/low-level views for fixed width integers [u…
aaronj0 Apr 24, 2026
20805aa
[CPyCppyy] Fix typos, call GetActualClass in instance cast_actual [up…
aaronj0 Apr 23, 2026
a46cc68
[CPyCppyy] Add CStringArrayConverter::ToMemory and buffer helper [ups…
aaronj0 Apr 24, 2026
d346f3f
[CPyCppyy] Pythonize: fix __iadd__ return and disable buggy __array__…
aaronj0 Apr 24, 2026
0afca19
[CPyCppyy] Use complete basic_string<char> name with default template…
aaronj0 Apr 30, 2026
61bd3d8
[CPyCppyy] Match function-pointer overloads via TCppType_t [upstream]
aaronj0 May 4, 2026
30d2dfe
[CPyCppyy] declare gException, drop CPYCPPYY_IMPORT from CPPInstance …
aaronj0 Apr 24, 2026
fc15c85
[CPyCppyy] Add more converter/executor name aliases [ROOT-patch]
aaronj0 Apr 24, 2026
f9dcc77
[CPyCppyy] Rename PyInit_libcppyy to Init for ROOT module split [ROOT…
aaronj0 Apr 24, 2026
600e675
[CPyCppyy] Pythonize: add std::span support and no-std wstring aliase…
aaronj0 Apr 24, 2026
af9d0f5
[CPyCppyy] Add __template_args__ and signature-plus-template overload…
aaronj0 Apr 23, 2026
40b4257
[CPyCppyy] Always convert returned to Python string [ROOT-patch]
aaronj0 May 1, 2026
54798fd
[CPyCppyy] Fix false addition of STLSequenceIter for pointer return-t…
aaronj0 May 3, 2026
01a9e53
[pyroot] Exclude canonical std::string from generic pretty-printer [R…
aaronj0 May 1, 2026
58c118b
[Python] Pythonize templated classes cached in namespace [ROOT-patch]
aaronj0 May 21, 2026
417db49
[pyroot] Refactor RDF Filter/Define callable dispatch [ROOT-patch]
aaronj0 May 21, 2026
22607b0
[ROOT] Use value_type instead of string manipulation to pythonize stl…
aaronj0 May 11, 2026
c75dfae
[ROOT][test] Canonical name includes UL suffix for literal
aaronj0 May 11, 2026
54e4a48
[cppinterop] Null-guard GetClassTemplateInstantiationArgs [upstream]
aaronj0 Jul 11, 2026
aea239d
[cppyy-backend] Resolve template arguments with real C++ unqualified …
aaronj0 Jul 11, 2026
00e76ef
[cppyy] Serialize CppInterOp calls with ROOT's interpreter lock
guitargeek Jul 14, 2026
5eadceb
[cppinterop] Use `::new` in wrappers that placement-new into a caller…
guitargeek Jul 14, 2026
b9ffb00
[CPyCppyy] Restore support for non-const void*& arguments [upstream]
guitargeek Jul 14, 2026
28221b7
[CPyCppyy] Cache anonymous-enum constant values in CPPDataMember [ups…
guitargeek Jul 14, 2026
adabe5a
[cppyy-backend] Resolve qualified names relative to a parent scope
guitargeek Jul 14, 2026
97cab17
[cppinterop] Keep template arguments qualified in GetCompleteName [up…
guitargeek Jul 14, 2026
ff9e249
[cppyy] Remove old patches and patching script for cppyy
guitargeek Jul 14, 2026
bed4046
[cppyy-backend] Fall back to per-candidate template instantiation in …
guitargeek Jul 14, 2026
757ad5b
[cppyy-backend] Filter deleted functions from Python-visible overload…
guitargeek Jul 14, 2026
bab341e
[cppinterop] Cycle through ambiguous lookups in ExistsFunctionTemplat…
guitargeek Jul 14, 2026
0c2a0a1
[cppinterop] Compile call wrappers without access control [upstream]
guitargeek Jul 14, 2026
9980fc6
[CPyCppyy] Exempt T* const& from the mutable pointer-reference ban
guitargeek Jul 14, 2026
3d75fb9
[CPyCppyy] Raise TypeError when a C++ name cannot be constructed
guitargeek Jul 14, 2026
b913384
[cppinterop] Do not expose inherited special-member constructors [ups…
guitargeek Jul 14, 2026
981b32b
[cppinterop] Use the defining declaration's type for unbounded arrays…
guitargeek Jul 14, 2026
7c289c3
[CPyCppyy] Re-enable __array__ for vectors of non-class element types
guitargeek Jul 14, 2026
5657dae
[cppyy-backend] Normalize exposed names to cppyy's canonical form
guitargeek Jul 14, 2026
2d97868
[cppinterop] Reject ill-formed instantiations in BestOverloadFunction…
guitargeek Jul 14, 2026
bbf6854
[cppyy-backend] Resolve cppyy.gbl.gROOT to its underlying variable
guitargeek Jul 14, 2026
ebf9ffb
[CPyCppyy] Only pythonize size() as __len__ for integer-sized containers
guitargeek Jul 14, 2026
c9b4fb2
[cppinterop] Make IsAbstract safe for classes without a definition [u…
guitargeek Jul 14, 2026
29397a8
[CPyCppyy] Auto-downcast polymorphic pointers read from memory
guitargeek Jul 14, 2026
597c131
[CPyCppyy] Initialize pytc in TemplateProxy::Instantiate [upstream]
guitargeek Jul 15, 2026
8662ab8
[cppyy-backend] Fix compiler warnings
guitargeek Jul 15, 2026
23a0728
[roottest] Adapt atlas-datavector template instantiation test to new …
guitargeek Jul 15, 2026
712a16c
[CPyCppyy] Do not declare the Cppyy API dllimport on Windows
guitargeek Jul 15, 2026
9ab2ad3
[CPyCppyy] Retry template lookup with 2-tuples typed as std::pair
guitargeek Jul 15, 2026
f179a43
[cppinterop] Open a transaction before lookups that may deserialize […
guitargeek Jul 15, 2026
20e3343
[cppyy] Do not let the Windows std::endl workaround break the import
guitargeek Jul 15, 2026
f1f8b4f
[cppinterop] Search base classes in GetNamed for class scopes [upstream]
guitargeek Jul 15, 2026
b875719
[CPyCppyy] Type Python complex as std::complex<double> in template args
guitargeek Jul 15, 2026
75bc012
[cppinterop] Print type and scope names platform-independently [upstr…
guitargeek Jul 16, 2026
c9e4fb9
[cppyy-backend] Add env-guarded tracing of JIT calls
guitargeek Jul 16, 2026
d92d15d
[cppinterop] Guard GetSizeOfType against a null type [upstream]
guitargeek Jul 16, 2026
facd684
[cppyy-backend] Do not call with an unsizable return buffer in CallO
guitargeek Jul 16, 2026
7bd82c6
[RF] Delete fit objects before continuing in rs401d_FeldmanCousins.py
guitargeek Jul 16, 2026
b6894fe
[cppinterop] Skip linkage specs when walking up parent scopes [upstream]
guitargeek Jul 17, 2026
9ac4f04
[cppinterop] Use IsCopyConstructorDeleted for by-value args in calls …
guitargeek Jul 17, 2026
6f9023d
[cling] Never resolve JIT symbols against legacy MSVC runtimes
guitargeek Jul 17, 2026
e854853
[cppyy-backend] Instantiate templated operator-> in smart-ptr detection
guitargeek Jul 17, 2026
700ab18
[cppinterop] Resolve globals whose symbol exists in no loaded binary …
guitargeek Jul 14, 2026
2f4af2c
[cppyy] Do not implicitly convert to unrelated stdlib implementation …
guitargeek Jul 17, 2026
293f066
[cppinterop] Return enum constant values as their int64_t bit pattern…
aaronj0 May 11, 2026
4de0219
[DF][Python] Enable ROOT thread safety on the distributed client
guitargeek Jul 17, 2026
b254af6
[cppyy] Detect cppexec errors from the captured diagnostics
guitargeek Jul 18, 2026
c8cb96a
[misc] Export named read-only data from bindexplib
guitargeek Jul 18, 2026
4d22d7a
[misc] Restrict bindexplib read-only data exports to C++-mangled names
guitargeek Jul 18, 2026
85032ad
[cppinterop] Keep only public using-shadows in class enumeration [ups…
guitargeek Jul 19, 2026
9c9ec60
[cppyy] Expose non-public methods re-exposed via public using-declara…
guitargeek Jul 19, 2026
18a6e34
[cppyy] Use comparison operators inherited from base classes
guitargeek Jul 19, 2026
b037467
[cppinterop] Require public path between same-template base instantia…
guitargeek Jul 19, 2026
47ebe6b
[cppyy] Search the global scope before the left operand's namespace f…
guitargeek Jul 19, 2026
96e2903
[roottest] Disable python-cling-api on Windows
guitargeek Jul 19, 2026
d0bb6c0
[tutorials] Disable the fitNormSum Python tutorial test on Windows 32…
guitargeek Jul 19, 2026
b52daf8
[CPyCppyy] Honor the global policy flag for implicit smart pointer co…
guitargeek Jul 19, 2026
0ee5193
[cppyy-backend] Don't autocast to anonymous-namespace types in GetAct…
guitargeek Jul 21, 2026
5e60e29
[cppyy] Adjust cppyy test expectations for the interop migration [ROO…
aaronj0 Apr 26, 2026
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: 13 additions & 0 deletions bindings/distrdf/python/DistRDF/Backends/Base.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,19 @@ class BaseBackend(ABC):
shared_libraries = set()
strings_to_declare = dict()

def __init__(self):
# Enable ROOT thread safety on the client side. Distributed backends
# drive ROOT from more than one thread in the user's process: besides
# the main thread, the scheduler client (e.g. the Dask IO loop thread)
# deserializes the ROOT result objects coming back from the workers.
# That deserialization goes through the cling interpreter (TClass,
# wrapper compilation, ...), so it can run concurrently with interpreter
# activity on the main thread. Without thread safety enabled the
# unsynchronized access corrupts the interpreter state and leads to
# sporadic crashes. This mirrors the ROOT.EnableThreadSafety() call done
# on the workers in setup_mapper().
ROOT.EnableThreadSafety()

@classmethod
def register_initialization(cls, fun, *args, **kwargs):
"""
Expand Down
31 changes: 21 additions & 10 deletions bindings/pyroot/cppyy/CPyCppyy/include/CPyCppyy/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,27 @@
#endif
#include "Python.h"

#define CPYCPPYY_VERSION_HEX 0x010c10
#define CPYCPPYY_VERSION_HEX 0x011200

// Cppyy types
#ifndef CPYCPPYY_INTERNAL

namespace Cpp {
struct DeclRef;
struct TypeRef;
struct FuncRef;
struct ObjectRef;
} // namespace Cpp

namespace Cppyy {
typedef size_t TCppScope_t;
typedef TCppScope_t TCppType_t;
typedef void* TCppEnum_t;
typedef void* TCppObject_t;
typedef intptr_t TCppMethod_t;

typedef size_t TCppIndex_t;
typedef void* TCppFuncAddr_t;
typedef Cpp::DeclRef TCppScope_t;
typedef Cpp::TypeRef TCppType_t;
typedef Cpp::ObjectRef TCppObject_t;
typedef Cpp::FuncRef TCppMethod_t;
typedef size_t TCppIndex_t;
typedef void* TCppFuncAddr_t;
} // namespace Cppyy
#endif

// Bindings
#include "CPyCppyy/CommonDefs.h"
Expand Down Expand Up @@ -123,6 +131,7 @@ class CPYCPPYY_CLASS_EXTERN Converter {

// create a converter based on its full type name and dimensions
CPYCPPYY_EXTERN Converter* CreateConverter(const std::string& name, cdims_t = 0);
CPYCPPYY_EXTERN Converter* CreateConverter(Cppyy::TCppType_t type, cdims_t = 0);

// delete a previously created converter
CPYCPPYY_EXTERN void DestroyConverter(Converter* p);
Expand Down Expand Up @@ -153,6 +162,7 @@ class CPYCPPYY_CLASS_EXTERN Executor {

// create an executor based on its full type name
CPYCPPYY_EXTERN Executor* CreateExecutor(const std::string& name, cdims_t = 0);
CPYCPPYY_EXTERN Executor* CreateExecutor(Cppyy::TCppType_t type, cdims_t = 0);

// delete a previously created executor
CPYCPPYY_EXTERN void DestroyConverter(Converter* p);
Expand Down Expand Up @@ -183,7 +193,8 @@ CPYCPPYY_EXTERN void* Instance_AsVoidPtr(PyObject* pyobject);
// void* to C++ Instance (python object proxy) conversion, returns a new reference
CPYCPPYY_EXTERN PyObject* Instance_FromVoidPtr(
void* addr, const std::string& classname, bool python_owns = false);

CPYCPPYY_EXTERN PyObject* Instance_FromVoidPtr(
void* addr, Cppyy::TCppScope_t klass_scope, bool python_owns = false);
// type verifiers for C++ Scope
CPYCPPYY_EXTERN bool Scope_Check(PyObject* pyobject);
CPYCPPYY_EXTERN bool Scope_CheckExact(PyObject* pyobject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@
#ifdef _MSC_VER
// Windows requires symbols to be explicitly exported
#define CPYCPPYY_EXPORT extern __declspec(dllexport)
#define CPYCPPYY_IMPORT extern __declspec(dllimport)
#define CPYCPPYY_CLASS_EXPORT __declspec(dllexport)

// CPYCPPYY_EXTERN is dual use in the public API
#ifndef CPYCPPYY_INTERNAL
#define CPYCPPYY_EXTERN extern __declspec(dllexport)
#define CPYCPPYY_CLASS_EXTERN __declspec(dllexport)
#else
#define CPYCPPYY_EXTERN extern
#define CPYCPPYY_CLASS_EXTERN
#define CPYCPPYY_EXTERN extern __declspec(dllimport)
#define CPYCPPYY_CLASS_EXTERN __declspec(dllimport)
#endif

#define CPYCPPYY_STATIC

#else
// Linux, Mac, etc.
#define CPYCPPYY_EXPORT extern
#define CPYCPPYY_IMPORT extern
#define CPYCPPYY_CLASS_EXPORT
#define CPYCPPYY_EXTERN extern
#define CPYCPPYY_CLASS_EXTERN
#define CPYCPPYY_STATIC static

#endif

#define CPYCPPYY_IMPORT extern

#endif // !CPYCPPYY_COMMONDEFS_H
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@

// Bindings
#include "CPyCppyy/CommonDefs.h"

#include <Python.h>

namespace CPyCppyy {
class PythonGILRAII {
PyGILState_STATE state;

public:
PythonGILRAII() : state(PyGILState_Ensure()) {}
~PythonGILRAII() { PyGILState_Release(state); }
};

class CPYCPPYY_CLASS_EXTERN DispatchPtr {
public:
Expand Down
65 changes: 41 additions & 24 deletions bindings/pyroot/cppyy/CPyCppyy/src/API.cxx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Bindings
#include "CPyCppyy.h"
#include "Cppyy.h"
#define CPYCPPYY_INTERNAL 1
#include "CPyCppyy/API.h"
#undef CPYCPPYY_INTERNAL

#include "CPPInstance.h"
#include "CPPOverload.h"
#include "CPPScope.h"
#include "CPyCppyy/DispatchPtr.h"
#include "ProxyWrappers.h"
#include "PyStrings.h"

Expand Down Expand Up @@ -46,22 +48,10 @@ static bool Initialize()

if (!Py_IsInitialized()) {
// this happens if Cling comes in first
#if PY_VERSION_HEX < 0x03020000
PyEval_InitThreads();
#endif
#if PY_VERSION_HEX < 0x03080000
Py_Initialize();
#else
PyConfig config;
PyConfig_InitPythonConfig(&config);
PyConfig_SetString(&config, &config.program_name, L"cppyy");
Py_InitializeFromConfig(&config);
#endif
#if PY_VERSION_HEX >= 0x03020000
#if PY_VERSION_HEX < 0x03090000
PyEval_InitThreads();
#endif
#endif

// try again to see if the interpreter is initialized
if (!Py_IsInitialized()) {
Expand All @@ -70,21 +60,12 @@ static bool Initialize()
return false;
}

// set the command line arguments on python's sys.argv
#if PY_VERSION_HEX < 0x03000000
char* argv[] = {const_cast<char*>("cppyy")};
#elif PY_VERSION_HEX < 0x03080000
wchar_t* argv[] = {const_cast<wchar_t*>(L"cppyy")};
#endif
#if PY_VERSION_HEX < 0x03080000
PySys_SetArgv(sizeof(argv)/sizeof(argv[0]), argv);
#endif

// force loading of the cppyy module
PyRun_SimpleString(const_cast<char*>("import cppyy"));
}

if (!gMainDict) {
CPyCppyy::PythonGILRAII python_gil_raii;
// retrieve the main dictionary
gMainDict = PyModule_GetDict(
PyImport_AddModule(const_cast<char*>("__main__")));
Expand All @@ -110,7 +91,7 @@ std::string CPyCppyy::Instance_GetScopedFinalName(PyObject* pyobject)
return "";
}

Cppyy::TCppType_t pyobjectClass = ((CPPInstance *)pyobject)->ObjectIsA();
Cppyy::TCppScope_t pyobjectClass = ((CPPInstance *)pyobject)->ObjectIsA();
return Cppyy::GetScopedFinalName(pyobjectClass);
}

Expand All @@ -121,6 +102,8 @@ void* CPyCppyy::Instance_AsVoidPtr(PyObject* pyobject)
if (!Initialize())
return nullptr;

PythonGILRAII python_gil_raii;

// check validity of cast
if (!CPPInstance_Check(pyobject))
return nullptr;
Expand All @@ -137,6 +120,8 @@ PyObject* CPyCppyy::Instance_FromVoidPtr(
if (!Initialize())
return nullptr;

PythonGILRAII python_gil_raii;

// perform cast (the call will check TClass and addr, and set python errors)
PyObject* pyobject = BindCppObjectNoCast(addr, Cppyy::GetScope(classname), false);

Expand All @@ -147,6 +132,25 @@ PyObject* CPyCppyy::Instance_FromVoidPtr(
return pyobject;
}

//-----------------------------------------------------------------------------
PyObject* CPyCppyy::Instance_FromVoidPtr(
void* addr, Cppyy::TCppScope_t klass_scope, bool python_owns)
{
// Bind the addr to a python object of class defined by classname.
if (!Initialize())
return nullptr;

PythonGILRAII python_gil_raii;

// perform cast (the call will check TClass and addr, and set python errors)
PyObject* pyobject = BindCppObjectNoCast(addr, klass_scope, false);

// give ownership, for ref-counting, to the python side, if so requested
if (python_owns && CPPInstance_Check(pyobject))
((CPPInstance*)pyobject)->PythonOwns();

return pyobject;
}
namespace CPyCppyy {
// version with C type arguments only for use with Numba
PyObject* Instance_FromVoidPtr(void* addr, const char* classname, int python_owns) {
Expand All @@ -161,6 +165,7 @@ bool CPyCppyy::Scope_Check(PyObject* pyobject)
if (!Initialize())
return false;

PythonGILRAII python_gil_raii;
return CPPScope_Check(pyobject);
}

Expand All @@ -171,6 +176,7 @@ bool CPyCppyy::Scope_CheckExact(PyObject* pyobject)
if (!Initialize())
return false;

PythonGILRAII python_gil_raii;
return CPPScope_CheckExact(pyobject);
}

Expand All @@ -181,6 +187,7 @@ bool CPyCppyy::Instance_Check(PyObject* pyobject)
if (!Initialize())
return false;

PythonGILRAII python_gil_raii;
// detailed walk through inheritance hierarchy
return CPPInstance_Check(pyobject);
}
Expand All @@ -192,6 +199,7 @@ bool CPyCppyy::Instance_CheckExact(PyObject* pyobject)
if (!Initialize())
return false;

PythonGILRAII python_gil_raii;
// direct pointer comparison of type member
return CPPInstance_CheckExact(pyobject);
}
Expand Down Expand Up @@ -225,6 +233,7 @@ void CPyCppyy::Instance_SetCppOwns(PyObject* pyobject)
//-----------------------------------------------------------------------------
bool CPyCppyy::Sequence_Check(PyObject* pyobject)
{
PythonGILRAII python_gil_raii;
// Extends on PySequence_Check() to determine whether an object can be iterated
// over (technically, all objects can b/c of C++ pointer arithmetic, hence this
// check isn't 100% accurate, but neither is PySequence_Check()).
Expand Down Expand Up @@ -258,6 +267,7 @@ bool CPyCppyy::Sequence_Check(PyObject* pyobject)
//-----------------------------------------------------------------------------
bool CPyCppyy::Instance_IsLively(PyObject* pyobject)
{
PythonGILRAII python_gil_raii;
// Test whether the given instance can safely return to C++
if (!CPPInstance_Check(pyobject))
return true; // simply don't know
Expand All @@ -277,6 +287,7 @@ bool CPyCppyy::Overload_Check(PyObject* pyobject)
if (!Initialize())
return false;

PythonGILRAII python_gil_raii;
// detailed walk through inheritance hierarchy
return CPPOverload_Check(pyobject);
}
Expand All @@ -288,6 +299,7 @@ bool CPyCppyy::Overload_CheckExact(PyObject* pyobject)
if (!Initialize())
return false;

PythonGILRAII python_gil_raii;
// direct pointer comparison of type member
return CPPOverload_CheckExact(pyobject);
}
Expand All @@ -305,6 +317,8 @@ bool CPyCppyy::Import(const std::string& mod_name)
if (!Initialize())
return false;

PythonGILRAII python_gil_raii;

PyObject* mod = PyImport_ImportModule(mod_name.c_str());
if (!mod) {
PyErr_Print();
Expand Down Expand Up @@ -364,6 +378,8 @@ void CPyCppyy::ExecScript(const std::string& name, const std::vector<std::string
if (!Initialize())
return;

PythonGILRAII python_gil_raii;

// verify arguments
if (name.empty()) {
std::cerr << "Error: no file name specified." << std::endl;
Expand All @@ -388,7 +404,6 @@ void CPyCppyy::ExecScript(const std::string& name, const std::vector<std::string
// build new argv
const int argc = (int)args.size() + 1;
std::vector<wchar_t*> wargv(argc);

wargv[0] = Py_DecodeLocale(name.c_str(), nullptr);

for (int i = 1; i < argc; ++i) {
Expand Down Expand Up @@ -438,6 +453,7 @@ bool CPyCppyy::Exec(const std::string& cmd)
if (!Initialize())
return false;

PythonGILRAII python_gil_raii;
// execute the command
PyObject* result =
PyRun_String(const_cast<char*>(cmd.c_str()), Py_file_input, gMainDict, gMainDict);
Expand All @@ -459,6 +475,7 @@ void CPyCppyy::Prompt() {
if (!Initialize())
return;

PythonGILRAII python_gil_raii;
// enter i/o interactive mode
PyRun_InteractiveLoop(stdin, const_cast<char*>("\0"));
}
11 changes: 3 additions & 8 deletions bindings/pyroot/cppyy/CPyCppyy/src/CPPClassMethod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@


//- public members --------------------------------------------------------------
PyObject* CPyCppyy::CPPClassMethod::Call(CPPInstance*&
#if PY_VERSION_HEX >= 0x03080000
self
#endif
, CPyCppyy_PyArgs_t args, size_t nargsf, PyObject* kwds, CallContext* ctxt)
PyObject *CPyCppyy::CPPClassMethod::Call(CPPInstance *&self, CPyCppyy_PyArgs_t args,
size_t nargsf, PyObject *kwds, CallContext *ctxt)
{
// preliminary check in case keywords are accidently used (they are ignored otherwise)
if (kwds && ((PyDict_Check(kwds) && PyDict_Size(kwds)) ||
Expand All @@ -23,7 +20,6 @@ PyObject* CPyCppyy::CPPClassMethod::Call(CPPInstance*&
return nullptr;

// translate the arguments
#if PY_VERSION_HEX >= 0x03080000
// TODO: The following is not robust and should be revisited e.g. by making CPPOverloads
// that have only CPPClassMethods be true Python classmethods? Note that the original
// implementation wasn't 100% correct either (e.g. static size() mapped to len()).
Expand All @@ -35,12 +31,11 @@ PyObject* CPyCppyy::CPPClassMethod::Call(CPPInstance*&
if ((!self || (PyObject*)self == Py_None) && nargs) {
PyObject* arg0 = CPyCppyy_PyArgs_GET_ITEM(args, 0);
if (CPPInstance_Check(arg0) && fArgsRequired <= nargs - 1 &&
Cppyy::IsSubtype(reinterpret_cast<CPPInstance *>(arg0)->ObjectIsA(), GetScope())) {
Cppyy::IsSubclass(reinterpret_cast<CPPInstance *>(arg0)->ObjectIsA(), GetScope())) {
args += 1; // drops first argument
nargsf -= 1;
}
}
#endif

if (!this->ConvertAndSetArgs(args, nargsf, ctxt))
return nullptr;
Expand Down
Loading
Loading