From 9275b0346813289ffedd40d0ba0ccd67e71e75b3 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Fri, 15 Mar 2024 16:02:09 +0100 Subject: [PATCH] [PyROOT] Adopt to no conversion from `char[]` to Python `str` --- bindings/pyroot/pythonizations/src/TTreePyz.cxx | 3 ++- bindings/pyroot/pythonizations/test/ttree_branch_attr.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bindings/pyroot/pythonizations/src/TTreePyz.cxx b/bindings/pyroot/pythonizations/src/TTreePyz.cxx index 86b8888bc8ec1..0ebe51d9f1d59 100644 --- a/bindings/pyroot/pythonizations/src/TTreePyz.cxx +++ b/bindings/pyroot/pythonizations/src/TTreePyz.cxx @@ -95,6 +95,7 @@ static PyObject *BindBranchToProxy(TTree *tree, const char *name, TBranch *branc static PyObject *WrapLeaf(TLeaf *leaf) { if (1 < leaf->GetLenStatic() || leaf->GetLeafCount()) { + bool isStatic = 1 < leaf->GetLenStatic(); // array types std::string typeName = leaf->GetTypeName(); #ifdef CPYCPPYY_VERSION_HEX @@ -103,7 +104,7 @@ static PyObject *WrapLeaf(TLeaf *leaf) #else dim_t dims[]{ 1, leaf->GetNdata() }; // first entry is the number of dims #endif - Converter *pcnv = CreateConverter(typeName + '*', dims); + Converter *pcnv = CreateConverter(typeName + (isStatic ? "[]" : "*"), dims); void *address = 0; if (leaf->GetBranch()) diff --git a/bindings/pyroot/pythonizations/test/ttree_branch_attr.py b/bindings/pyroot/pythonizations/test/ttree_branch_attr.py index 55e3df191da73..e28b29f7e9635 100644 --- a/bindings/pyroot/pythonizations/test/ttree_branch_attr.py +++ b/bindings/pyroot/pythonizations/test/ttree_branch_attr.py @@ -88,11 +88,11 @@ def test_char_array_branch(self): f,t,c = self.get_tree_and_chain() for ds in t,c: - self.assertEqual(ds.chararrayb, 'one') + self.assertEqual(ds.chararrayb.as_string(), 'one') ds.GetEntry(1) - self.assertEqual(ds.chararrayb, 'onetwo') + self.assertEqual(ds.chararrayb.as_string(), 'onetwo') def test_vector_branch(self): f,t,c = self.get_tree_and_chain()