Uploaded image for project: 'Instrument control development'
  1. Instrument control development
  2. INSTRM-383

String keywords not always escaped in a way which can be predictably unescaped.

    XMLWordPrintable

    Details

      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.
      

        Attachments

          Activity

            People

            • Assignee:
              cloomis cloomis
              Reporter:
              cloomis cloomis
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: