[Webkit-unassigned] [Bug 264237] [meta] Python CGI should use binary mode for stdout for Windows Python

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Feb 3 22:23:16 PST 2025


https://bugs.webkit.org/show_bug.cgi?id=264237

--- Comment #4 from Kohei Asano <kohei.asano at sony.com> ---
I tried to fix by the following shell script, but its lines are much more than I expected, I'm not so sure it's worth to apply all, but I leave this for notes

```
I inserted by the following shell scripts, and it was 

#!/bin/bash

TARGET_DIR="LayoutTests"

grep -rl 'sys.stdout.write' "$TARGET_DIR" --include="*.py" | while read -r file; do
    tmpfile=$(mktemp)
    inserted=0

    while IFS= read -r line || [[ -n "$line" ]]; do
        echo "$line" >> "$tmpfile"

        if [[ $line =~ ^[[:space:]]*import\ sys$ ]]; then
            indent=$(echo "$line" | grep -o '^[[:space:]]*')
            echo "${indent}sys.stdout.reconfigure(newline=\"\")  # prevent windows \n -> \n\r conversion" >> "$tmpfile"
        fi
    done < "$file"

    mv "$tmpfile" "$file"
done

```

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20250204/2e0deb41/attachment.htm>


More information about the webkit-unassigned mailing list