1 parent 98d1303 commit 221bd2dCopy full SHA for 221bd2d
1 file changed
src/serialize_ast.rs
@@ -196,7 +196,15 @@ pub(crate) fn serialize_python_file(
196
let source_type = PySourceType::from(file_path);
197
let source_text = match source {
198
Some(source_text) => source_text,
199
- None => &std::fs::read_to_string(file_path)?,
+ None => &{
200
+ let content = std::fs::read_to_string(file_path)?;
201
+ if !content.contains('\r') {
202
+ // Fast path: nothing to normalize.
203
+ content
204
+ } else {
205
+ content.replace("\r\n", "\n").replace("\r", "\n")
206
+ }
207
+ },
208
};
209
210
// Compute SHA1 hash of the source text (same as mypy's compute_hash)
0 commit comments