Make md5 hash independent of platform line endings#722
Merged
larsoner merged 4 commits intosphinx-gallery:masterfrom Jul 7, 2020
Merged
Make md5 hash independent of platform line endings#722larsoner merged 4 commits intosphinx-gallery:masterfrom
larsoner merged 4 commits intosphinx-gallery:masterfrom
Conversation
Currently md5 hash for Python files depends on what platform file is on, as file endings will differ. This change reads the Python files in the hashing function with universal line endings, such md5 is independent of platform being used. Surrogate escapes are used, to ensure that it can handle any errors without data loss. This is useful when adding a complex or long running examples into a repository that may be used across platforms.
Codecov Report
@@ Coverage Diff @@
## master #722 +/- ##
=======================================
Coverage 97.47% 97.47%
=======================================
Files 32 32
Lines 3560 3571 +11
=======================================
+ Hits 3470 3481 +11
Misses 90 90
Continue to review full report at Codecov.
|
Contributor
|
Thanks @sdhiscocks. Maybe we could also add a test in |
Contributor
|
Sure, seems like that would work |
5fb27e5 to
e872f97
Compare
lucyleeow
approved these changes
Jun 30, 2020
Contributor
|
Thanks @sdhiscocks, @larsoner merge when you're happy/CI's green! |
larsoner
reviewed
Jun 30, 2020
This ensures consisted md5sum for text files e.g. Python files, and IPython Notebooks; but valid md5sums for binary files.
Contributor
|
Thanks @sdhiscocks ! |
sdhiscocks
added a commit
to sdhiscocks/sphinx-gallery
that referenced
this pull request
Aug 3, 2023
This resolves an issue where the system default encoding for opening a file is not UTF-8, whereas the encoding default for string encode method is UTF-8, and such hash differs depending on OS. Related to sphinx-gallery#722 which originally attempted to resolve inconsistencies across OSs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently md5 hash for Python files depends on what platform file is on, as file endings will differ. This change reads the Python files in the hashing function with universal line endings, such md5 is independent of platform being used.
Surrogate escapes are used, to ensure that it can handle any errors without data loss.
This is useful when adding a complex or long running examples into a repository that may be used across platforms.