fix(SU2_PY): improve Python wrapper reliability and remove invalid-escape warnings by shbhmexe · Pull Request #2650 · su2code/SU2

Proposed Changes

This PR contains small, behavior-preserving fixes in SU2’s Python tooling:

  • SU2_PY/SU2/run/interface.py: make run_command() safer and more reliable by using communicate() to avoid stderr pipe deadlocks, improving stderr decoding robustness, and fixing a wrong “Path = …” diagnostic.
  • SU2_PY/OptimalPropeller.py: use raw strings for matplotlib labels to avoid invalid escape sequence warnings and ensure LaTeX-like labels render correctly.
  • SU2_PY/parallel_computation_fsi.py: remove a duplicated assignment in solution merge setup.

Issues found and fixed (tool-related)

  1. SU2_PY/SU2/run/interface.pyrun_command() robustness
  • Fixes a potential deadlock/hang scenario by switching from wait() + stderr.read() to communicate() (drains stderr while the process runs).
  • Makes stderr decoding robust (errors="replace") to avoid wrapper crashes on non-UTF8 output (common on Windows).
  • Fixes an incorrect diagnostic path in the error message (os.path.abspath(",")os.path.abspath(".")).
  1. SU2_PY/OptimalPropeller.py – invalid escape sequence warnings
  • Converts matplotlib label strings to raw strings so LaTeX-like expressions don’t trigger SyntaxWarning: invalid escape sequence and render as intended.
  1. SU2_PY/parallel_computation_fsi.py – redundant assignment
  • Removes a duplicated config.SOLUTION_FILENAME = config.RESTART_FILENAME line (no behavior change, but prevents confusion and keeps merge setup consistent).

Reasoning / Impact

  • Improves reliability of the Python wrapper when running external SU2 commands (prevents rare hangs, improves error reporting).
  • Removes Python warnings that can break strict CI configurations (e.g., treating warnings as errors) and improves correctness of plot labels.
  • No new features and no solver behavior changes intended.

Validation

  • python -m compileall SU2_PY succeeds.
  • Changes are localized and do not alter solver inputs/outputs; they only improve robustness/clarity in wrapper behavior.