Skip to content

Gaudi parser cannot handle python tuples with exactly one element

Re-posting from GAUDI-1272, which seems not to have been picked up after a year and a half...

The following sequence of operations fails:

  1. Declare a tool/alg with a vector property
  2. Set the value in python as a list with only one element
  3. Lock the tool. This causes initialisation to fail because the list is converted to a tuple, and the Gaudi parsers apparently cannot cope with the python syntax:
#include "GaudiKernel/Parsers.h"
std::vector<int> out;
Gaudi::Parsers::parse(out,"(0,1)").isSuccess() //this is true!
Gaudi::Parsers::parse(out,"(0,)").isSuccess() //this is false!

– example from ROOT prompt thanks to Will Buttinger. An Athena-based example is at /afs/cern.ch/work/k/khoo/public/OneElementListTest. Presumably the parsers should be taught to recognise the special case of "(something,)" which denotes a one-element tuple, so they don't attempt to split the string on ',' in this case.

Edited by Teng Jian Khoo
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information