[GRASS-git] [OSGeo/grass] 78edff: init: Fix SyntaxWarning: invalid escape sequence i...

Dung Ho noreply at github.com
Thu Aug 21 06:03:05 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: 78edffdc0d74224bff44c84cbd6ccf9b711cd61b
      https://github.com/OSGeo/grass/commit/78edffdc0d74224bff44c84cbd6ccf9b711cd61b
  Author: Dung Ho <htdung820 at gmail.com>
  Date:   2025-08-21 (Thu, 21 Aug 2025)

  Changed paths:
    M lib/init/grass.py

  Log Message:
  -----------
  init: Fix SyntaxWarning: invalid escape sequence in grass.py (#6239)

# Fix SyntaxWarning: invalid escape sequence in grass.py

## Problem
Python script generates SyntaxWarning and RuntimeError on Windows:

```
C:\opt\grass\build\output\bin\grass85.py:2095: SyntaxWarning: invalid escape sequence '\o'
  GRASS_PYDIR = os.path.normpath("C:\opt\grass\build\output\lib\grass85\etc\python")
Traceback (most recent call last):
  File "C:\opt\grass\build\output\bin\grass85.py", line 2473, in <module>
    main()
    ~~~~^^
  File "C:\opt\grass\build\output\bin\grass85.py", line 2118, in main
    find_grass_python_package()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "C:\opt\grass\build\output\bin\grass85.py", line 2106, in find_grass_python_package
    raise RuntimeError(msg)
RuntimeError: The grass Python package is missing. Is the installation of GRASS complete?
```


## Solution
Convert string literal to raw string to properly handle backslashes in Windows paths.

## Changes
- Changed `"@GRASS_PYDIR@"` to `r"@GRASS_PYDIR@"` in the `find_grass_python_package()` function

This eliminates the SyntaxWarning about invalid escape sequence `\o` and ensures proper path handling on Windows systems.

Fixes Python syntax warning that occurs during GRASS GIS initialization on Windows.



To unsubscribe from these emails, change your notification settings at https://github.com/OSGeo/grass/settings/notifications


More information about the grass-commit mailing list