Secure line ending in .py files used for caching tests

Otherwise, automatic line ending conversion might affect SHA 256 hashes
calculated in test data based on its content. It allowed to uniformly
compute it both for binary and text files.

GitOrigin-RevId: b41ff089235c178b182271a81a26146cff54e053
This commit is contained in:
Mikhail Golubev
2019-06-10 19:52:07 +03:00
committed by intellij-monorepo-bot
parent d11d689e6b
commit 8d6daccfeb
2 changed files with 5 additions and 8 deletions
+2 -8
View File
@@ -377,14 +377,8 @@ def builtin_module_hash(mod_qname):
def physical_module_hash(mod_path):
pure_py = os.path.splitext(mod_path)[1] == '.py'
if pure_py:
# Open .py files in text mode to avoid LF/CRLF conversion issues. It should happen only in tests.
with fopen(mod_path, 'r') as f:
return sha256_digest(f.read().encode(OUT_ENCODING))
else:
with fopen(mod_path, 'rb') as f:
return sha256_digest(f)
with fopen(mod_path, 'rb') as f:
return sha256_digest(f)
def version_to_tuple(version):
+3
View File
@@ -0,0 +1,3 @@
# In these files persistent line endings are crucial
# as we use their binary content for hashes.
generator3_tests/data/SkeletonCaching/**/*.py text eol=lf