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

SWIG code enclosed in %python %{ should be outdented to the left margin

    Details

    • Templates:
    • Team:
      SQuaRE

      Description

      In swig .i files code contained in %pythoncode %

      {...%}

      blocks must be outdented to the left margin for the code to be reliably correctly indented in the interface file and and for comments that start with # to be reliably handled as comments.

      Comments may have leading characters deleted (including the #) which can lead to part of the comment being treated as code. Another failure mode is that the comment has the wrong indentation level. Fortunately these errors usually result a syntax error, or are innocuous.

      Incorrectly indented code can lead to errors that are very hard to detect. One common result is that the added function appears as as a function definition inside another function. Hence the failure produces no python syntax errors, but the added function cannot be called.

      The problem does not always lead to improperly indented code and in some cases I suspect the code is being correctly indented, since I doubt it would work otherwise. Even then it is safest to fix the problem, if only to provide a correct example for others.

        Attachments

          Container Issues

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                rowen Russell Owen
                Watchers:
                Jim Bosch, John Swinbank, Kian-Tat Lim, Paul Price, Robert Lupton, Robyn Allsman [X] (Inactive), Russell Owen, Serge Monkewitz, Simon Krughoff, Tim Jenness
              • Votes:
                0 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel