Skip to content

Commit

Permalink
[PyROOT] Adopt to no conversion from char[] to Python str
Browse files Browse the repository at this point in the history
  • Loading branch information
guitargeek committed Mar 16, 2024
1 parent c8f2cdf commit b3a666d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bindings/pyroot/pythonizations/src/TTreePyz.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions bindings/pyroot/pythonizations/test/ttree_branch_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b3a666d

Please sign in to comment.