fix pyexpat by youknowone · Pull Request #6582 · RustPython/RustPython
🏁 Script executed:
#!/bin/bash # First, let's examine the actual file and the Parse method cd /tmp && find . -name "pyexpat.rs" -path "*/stdlib/src/*" 2>/dev/null | head -1
Repository: RustPython/RustPython
Length of output: 47
🏁 Script executed:
#!/bin/bash # List files in the stdlib crates directory find . -path "*/stdlib/src*" -name "*.rs" | head -20
Repository: RustPython/RustPython
Length of output: 665
🏁 Script executed:
#!/bin/bash # Examine the pyexpat.rs file around the specified lines cat -n crates/stdlib/src/pyexpat.rs | sed -n '310,350p'
Repository: RustPython/RustPython
Length of output: 1799
🏁 Script executed:
#!/bin/bash # Search for Parse method definition and all its usages rg -n "fn parse|\.parse\(" crates/stdlib/src/pyexpat.rs -A 2
Repository: RustPython/RustPython
Length of output: 468
🏁 Script executed:
#!/bin/bash # Check if Parse is a public method and look for any breaking change documentation rg -n "pub.*parse|parse.*Either|PyBytesRef" crates/stdlib/src/pyexpat.rs -B 2 -A 5
Repository: RustPython/RustPython
Length of output: 719
🏁 Script executed:
#!/bin/bash # Check the PyBytesRef definition to verify as_bytes() method exists rg -n "impl.*PyBytesRef|fn as_bytes" --type=rust -B 2 -A 5 | head -50
Repository: RustPython/RustPython
Length of output: 2637
🏁 Script executed:
#!/bin/bash # Look for the definition of PyBytesRef and its methods fd -e rs -x rg "pub.*as_bytes|PyBytesRef" {} + | grep -i "as_bytes" | head -20
Repository: RustPython/RustPython
Length of output: 15647
🏁 Script executed:
#!/bin/bash # Check builtins module where PyBytesRef is likely defined find . -path "*/builtins*" -name "*.rs" | xargs rg -l "PyBytesRef" | head -5
Repository: RustPython/RustPython
Length of output: 230
🏁 Script executed:
#!/bin/bash # Look for PyBytesRef and its as_bytes method rg "impl.*PyBytes|fn as_bytes" -A 3 | head -40
Repository: RustPython/RustPython
Length of output: 1980
🏁 Script executed:
#!/bin/bash # Check if there are tests for the parse method rg -n "test.*parse|Parse" crates/stdlib/src/pyexpat.rs
Repository: RustPython/RustPython
Length of output: 988
🏁 Script executed:
#!/bin/bash # Check for any Python side behavior of Parse in tests fd -e py -path "*/test*" -exec rg -l "Parse\|pyexpat" {} \; | head -5
Repository: RustPython/RustPython
Length of output: 233
🏁 Script executed:
#!/bin/bash # Verify PyBytesRef specifically has as_bytes() method rg -n "impl.*PyBytes|pub struct PyBytes" crates/vm/src/builtins/bytes.rs -A 10 | head -40
Repository: RustPython/RustPython
Length of output: 921
🏁 Script executed:
#!/bin/bash # Check the PyBytesRef type definition to ensure it wraps PyBytesInner rg -n "type PyBytesRef|pub.*PyBytesRef" crates/vm/src/builtins/bytes.rs -B 2 -A 2
Repository: RustPython/RustPython
Length of output: 154
🏁 Script executed:
#!/bin/bash # Check PyBytes as_bytes() method implementation rg -n "impl.*PyBytes|fn as_bytes" crates/vm/src/builtins/bytes.rs -A 3 | head -50
Repository: RustPython/RustPython
Length of output: 1518
🏁 Script executed:
#!/bin/bash # Find the actual as_bytes() method definition in PyBytes rg -n "pub.*fn as_bytes|fn as_bytes" crates/vm/src/builtins/bytes.rs -B 2 -A 3
Repository: RustPython/RustPython
Length of output: 178
Implementation is correct, but the signature change is not actually breaking.
Both PyStrRef and PyBytesRef have as_bytes() methods, and the conversion to Vec<u8> properly handles both string (UTF-8) and bytes inputs. However, the signature change from accepting PyStrRef to Either<PyStrRef, PyBytesRef> is backward compatible—existing code passing strings continues to work. This is a feature expansion, not a breaking change.
Note: The method has no error handling; do_parse() is called without checking its result.