Loading
Honour the explicit format argument of seqStr_2_obj
TL;DR
tango.utils.seqStr_2_objnow converts correctly when an explicittg_formatis passed. It previously returned an empty list for everySPECTRUMinput, and forIMAGEinput of any type other than string, integer or float.- A scalar type with no array equivalent, such as
DevEnum, now raisesValueErrornaming the type instead of a bareKeyError.
Reported in #789.
Key Facts
- The cause was transposed operands:
_seqStr_2_obj_from_typetakes(seq, tg_type), but all three calls from the format-aware helper passed(tg_type, seq). No type test could then match, so the conversion fell through to its empty-list fallback and returned[]rather than raising. Silent wrong results, not an error. - Two accidents limited the blast radius and are worth knowing when reviewing the diff:
AttrDataFormat.SCALARcompares equal to zero, so theif tg_format:gate treated an explicitSCALARas "no format given" and skipped the broken helper entirely, taking the correct path by luck. The gate now testsis not None. Fixing only the gate, without the operand order, would have turned a workingSCALARcall into a broken one.- The
IMAGEbranch open-coded its own conversion for string, integer and float using the correctly named operand, which is why only the remaining types reached the transposed call.
- The
IMAGEbranch now maps theSPECTRUMconversion over the rows instead of enumerating types. Converting an image row is converting a spectrum, so this removes the per-type special cases and makes boolean images work like the rest. - No in-tree caller is affected.
tango/device_class.pyis the only consumer and always omitstg_format, so it takes the unchanged no-format path. The fixed behaviour is reachable only through the public API, which is why nothing caught this. - Review hotspot:
scalar_to_array_type()replaces a direct_scalar_to_array_type[...]lookup. That is what converts theKeyErrorinto aValueError, and it applies to bothSPECTRUMandIMAGE.
Caveats
- The first commit adds the tests and fails on its own; the second makes them pass. Intentional, so the reproduction is in history.
IMAGEinput that is a flat sequence rather than a sequence of rows is malformed and was previously returned unchanged forDevString. It is now processed per row like any other type. No in-tree caller does this.