Simple-minded universal newline normalization - #90
Conversation
|
I think it would be better to compute the hash before normalization. |
JukkaL
left a comment
There was a problem hiding this comment.
This seems good enough, but I think it would be better to calculate the hash for the pre-normalized contents. Otherwise, file hashes will change when updating to a new version of ast_serialize, which seems at least unexpected (though maybe not a big deal).
Also if debugging file hash related issues, it would be nice if the mypy's internal hash function would match this one. I wonder if we rely on mypy's hash function being equivalent to this anywhere?
Yeah, this is exactly my worry as well. Unfortunately I can't really test anything as I don't have a Windows machine, but I will go again through the code and will trust Python docs (e.g. universal newlines should not apply when you read a file as bytes). |
|
When reading a file in binary mode (as bytes), cr/lf is preserved and the bytes should exactly match the file on disk. |
|
Sorry, I am being silly, I can simply play with
I will then update this PR accordingly. |
It looks like performance effect of this will be small anyway, so we can use a simple-minded solution for the problem described in python/mypy#21823 (comment). One thing I am not sure about is whether to compute hash before or after the normalization. cc @JukkaL