◐ Shell
clean mode source ↗

windows codecs by youknowone · Pull Request #6337 · RustPython/RustPython

🧩 Analysis chain

🏁 Script executed:

# Search for tests related to mbcs codec
rg -n "mbcs" --type=rs --type=py -i

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Look for error handler validation patterns in the codebase
rg -n "errors.*strict|ignore|replace" --type=rs | head -30

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Check the broader context around codecs.rs to understand how other encode functions handle errors
rg -n "errors.*as_ref|errors.*unwrap_or" --type=rs -B2 -A2

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Check the codecs.rs file structure to see if there are other encode functions
cat -n crates/vm/src/stdlib/codecs.rs | head -100

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Check the entire mbcs_encode function and surrounding context
sed -n '237,310p' crates/vm/src/stdlib/codecs.rs

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Check if there are other encode functions to see how they handle errors
grep -n "fn.*encode" crates/vm/src/stdlib/codecs.rs

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Let's see what other encoding functions look like to understand error handling patterns
sed -n '1,150p' crates/vm/src/stdlib/codecs.rs

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Let's also check if there are any other error-related constants being used
rg -n "CP_ACP|WC_NO_BEST_FIT_CHARS" --type=rs -B5 -A5

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Look for any test files that test this function
find . -name "*.rs" -type f | xargs grep -l "mbcs" 2>/dev/null

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Check if there are Python stdlib tests we can reference
find . -name "*.py" -type f | xargs grep -l "mbcs" 2>/dev/null | head -10

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Let's check the entire file to understand the error handling context
wc -l crates/vm/src/stdlib/codecs.rs

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Check the full codecs.rs file for other encode functions and their error handling
sed -n '100,250p' crates/vm/src/stdlib/codecs.rs

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Let's check if there are any comments or documentation about error handling in this file
grep -n "error\|Error\|ERROR" crates/vm/src/stdlib/codecs.rs | head -20

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Let's understand what the "errors" parameter should control by checking Python documentation
# and looking at the actual Windows API behavior
# Check if this function validates the errors parameter properly
sed -n '237,250p' crates/vm/src/stdlib/codecs.rs

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Check what MbcsEncodeArgs structure looks like
rg -n "struct MbcsEncodeArgs" --type=rs -A10

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Let's look at the broader context of the file
sed -n '1,50p' crates/vm/src/stdlib/codecs.rs

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Find the MbcsEncodeArgs definition
grep -n "MbcsEncodeArgs" crates/vm/src/stdlib/codecs.rs

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Get the definition of MbcsEncodeArgs
sed -n '210,236p' crates/vm/src/stdlib/codecs.rs

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Let's check if there's a utf_8_encode or similar function to see how errors are handled there
sed -n '50,150p' crates/vm/src/stdlib/codecs.rs | grep -A20 "fn utf"

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Let's look for any utf_8_encode function in the file
rg -n "fn utf_8_encode" --type=rs -A30

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Let's understand the complete behavior by looking at lines around mbcs_encode
sed -n '230,330p' crates/vm/src/stdlib/codecs.rs

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Check commit history for mbcs_encode changes
git log --all -p --follow -S "mbcs_encode" -- crates/vm/src/stdlib/codecs.rs | head -100

Repository: RustPython/RustPython

Length of output: 186


🏁 Script executed:

# Check the git blame to understand the history
git blame -L237,310 crates/vm/src/stdlib/codecs.rs | head -20

Repository: RustPython/RustPython

Length of output: 186


Implement error handling for non-strict error modes in mbcs_encode.

The current implementation only properly handles "strict" error mode. Non-strict modes ("ignore", "replace", "xmlcharrefreplace", "backslashreplace") lack proper implementation:

This causes non-strict error modes to exhibit undefined behavior dependent on the Windows MBCS implementation rather than Python's codec specification.