Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-8626

ConfigDictField cannot handle unicode keys in py2

    XMLWordPrintable

    Details

    • Story Points:
      1
    • Epic Link:
    • Sprint:
      Alert Production S17 - 12
    • Team:
      Alert Production

      Description

      Trying to use a unicode string as a key in a ConfigDictField causes a type error in Python 2. Unfortunately unicode is difficult to avoid with pybind11. I suggest trying to auto-cast such keys to str if the key is string-like and the type doesn't match the expected key type.

        Attachments

          Issue Links

            Activity

            Hide
            rowen Russell Owen added a comment - - edited

            I fixed the problem by adding a call to _autocast in ConfigDict.__setitem__ before checking the key type, just like Dict does. I also changed one key in the test of each to unicode to check the fix.

            Show
            rowen Russell Owen added a comment - - edited I fixed the problem by adding a call to _autocast in ConfigDict.__setitem__ before checking the key type, just like Dict does. I also changed one key in the test of each to unicode to check the fix.
            Hide
            tjenness Tim Jenness added a comment -

            Looks okay to me. I think we may want to use _autocast more widely but that's not the problem of this ticket to solve.

            Show
            tjenness Tim Jenness added a comment - Looks okay to me. I think we may want to use _autocast more widely but that's not the problem of this ticket to solve.

              People

              Assignee:
              rowen Russell Owen
              Reporter:
              rowen Russell Owen
              Reviewers:
              Tim Jenness
              Watchers:
              Russell Owen, Tim Jenness
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  CI Builds

                  No builds found.