Skip to content

Commit 6e7cf6c

Browse files
committed
fix: correctly handle python indentation
1 parent 07fb84a commit 6e7cf6c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

internal/runtime/langs.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package runtime
33
import (
44
"fmt"
55
"github.com/docker/docker/api/types/mount"
6+
"strings"
67
)
78

89
type containerContext struct {
@@ -72,6 +73,11 @@ try {
7273
}
7374

7475
func createPyContext(code string) *containerContext {
76+
codeLines := []string{}
77+
for _, line := range strings.Split(code, "\n") {
78+
codeLines = append(codeLines, fmt.Sprintf(" %s", line))
79+
}
80+
7581
wrapperFile := "wrapper.py"
7682
cmd := []string{"python", "/code/wrapper.py"}
7783
containerImage := "python:3.12-alpine"
@@ -91,7 +97,7 @@ try:
9197
exec(code)
9298
except Exception as e:
9399
print(json.dumps({'error': str(e)}))
94-
`, code,
100+
`, strings.Join(codeLines, "\n"),
95101
)
96102

97103
mounts := []mount.Mount{

0 commit comments

Comments
 (0)