]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
closes gh-99508: fix `TypeError` in `Lib/importlib/_bootstrap_external.py` (GH-99635)
authorNikita Sobolev <mail@sobolevn.me>
Wed, 23 Nov 2022 22:47:31 +0000 (01:47 +0300)
committerGitHub <noreply@github.com>
Wed, 23 Nov 2022 22:47:31 +0000 (16:47 -0600)
Lib/importlib/_bootstrap_external.py
Misc/NEWS.d/next/Library/2022-11-21-10-45-54.gh-issue-99508.QqVbby.rst [new file with mode: 0644]

index f4dbbebcd224c8363768c33e54bb454c1eb752d9..71a16064b8ec0a0aac67079991ba27743a4d0cb1 100644 (file)
@@ -1144,7 +1144,8 @@ class SourceLoader(_LoaderBasics):
                 source_mtime is not None):
             if hash_based:
                 if source_hash is None:
-                    source_hash = _imp.source_hash(source_bytes)
+                    source_hash = _imp.source_hash(_RAW_MAGIC_NUMBER,
+                                                   source_bytes)
                 data = _code_to_hash_pyc(code_object, source_hash, check_source)
             else:
                 data = _code_to_timestamp_pyc(code_object, source_mtime,
diff --git a/Misc/NEWS.d/next/Library/2022-11-21-10-45-54.gh-issue-99508.QqVbby.rst b/Misc/NEWS.d/next/Library/2022-11-21-10-45-54.gh-issue-99508.QqVbby.rst
new file mode 100644 (file)
index 0000000..82720d1
--- /dev/null
@@ -0,0 +1,2 @@
+Fix ``TypeError`` in ``Lib/importlib/_bootstrap_external.py`` while calling
+``_imp.source_hash()``.