;Bug Description
When executing render execute on Windows, the generated Python script contains Windows paths that are not properly escaped, causing a SyntaxError in Blender.
Environment
- Windows (confirmed on Windows 10/11)
- Blender 5.1.2
- Python path in script:
C:\Users\cr881\Desktop\_render_script.py
- Error:
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 19-20: truncated \UXXXXXXXX escape
Steps to Reproduce
cli-anything-blender scene new --name TestScene -o test_scene.json
cli-anything-blender --project test_scene.json object add cube -n "MyCube" -l "0,0,1"
cli-anything-blender light add sun -n "SunLight"
cli-anything-blender --project test_scene.json render execute "C:\Users\cr881\Desktop\blender_test.png" --overwrite
Then run the generated script directly with Blender:
blender --background --python C:\Users\cr881\Desktop\_render_script.py
Expected vs Actual
Expected: Blender renders the scene successfully to the specified PNG file.
Actual: Blender crashes with a syntax error because the Python script contains raw Windows paths (e.g., C:\Users\...) that Python interprets as Unicode escape sequences.
Root Cause
In the generated _render_script.py file, line 80 contains:
print('Render complete: C:\Users\cr881\Desktop\blender_test.png')
The backslashes in the Windows path need to be escaped as \\ or use a raw string / forward slashes.
Suggested Fix
Use forward slashes or proper path escaping in the generated render script:
- Option 1: Use
pathlib.Path or os.path.abspath to normalize paths
- Option 2: Replace
\ with \\ in string literals
- Option 3: Use raw strings (
r"C:\path") for file paths
- Option 4: Use forward slashes (
C:/Users/...) which Python and Blender both accept on Windows
Additional Context
- GIMP CLI works perfectly on Windows with no such issues
- This appears to be specific to the Blender harness render script generation
- The harness otherwise functions correctly (scene creation, object/light addition all work)
;Bug Description
When executing
render executeon Windows, the generated Python script contains Windows paths that are not properly escaped, causing aSyntaxErrorin Blender.Environment
C:\Users\cr881\Desktop\_render_script.pySyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 19-20: truncated \UXXXXXXXX escapeSteps to Reproduce
Then run the generated script directly with Blender:
Expected vs Actual
Expected: Blender renders the scene successfully to the specified PNG file.
Actual: Blender crashes with a syntax error because the Python script contains raw Windows paths (e.g.,
C:\Users\...) that Python interprets as Unicode escape sequences.Root Cause
In the generated
_render_script.pyfile, line 80 contains:The backslashes in the Windows path need to be escaped as
\\or use a raw string / forward slashes.Suggested Fix
Use forward slashes or proper path escaping in the generated render script:
pathlib.Pathoros.path.abspathto normalize paths\with\\in string literalsr"C:\path") for file pathsC:/Users/...) which Python and Blender both accept on WindowsAdditional Context