[INSTRM-383] String keywords not always escaped in a way which can be predictably unescaped. Created: 11/Jun/18  Updated: 13/Jun/18

Status: Open
Project: Instrument control development
Component/s: tron_actorcore
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Normal
Reporter: cloomis Assignee: cloomis
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Transferring headers from gen2Actor has uncovered an old mistake. The symptom is that only one of:

  header1 = r"""OBSERVER = '"Name, Other Name"' / double-quoted"""
  header2 = r"""OBSERVER = 'Name' / Not double-quoted"""

can make it through from one of:

  cmd.inform('header=%s' % (header))
  cmd.inform('header=%s' % (repr(header)))

to an identical string at the listener:

  header = self.actor.models['gen2']['header'].values[0]

I believe that the issue boils down to a pre-SDSS choice not to internally use repr to encode a string (because it does too much and makes strings ugly), but not fixing the decoding when SDSS switched to the opscore parser. Basically:

from opscore.utility.qstr import qstr

s = "any horrible thing"

# OK
eval(repr(s) == s # By definition

# Not OK
eval(qstr(repr(s)) != s # double-quotes get an additional escaping.
qstr(s) != s   # Of course not.

Generated at Sat Feb 10 16:24:26 JST 2024 using Jira 8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b.