[Python-checkins] closes gh-99508: fix `TypeError` in `Lib/importlib/_bootstrap_external.py` (GH-99635)

benjaminp webhook-mailer at python.org
Wed Nov 23 17:47:37 EST 2022


https://github.com/python/cpython/commit/c69cfcdb116c4907b306e2bd0e263d5ceba48bd5
commit: c69cfcdb116c4907b306e2bd0e263d5ceba48bd5
branch: main
author: Nikita Sobolev <mail at sobolevn.me>
committer: benjaminp <benjamin at locrian.net>
date: 2022-11-23T16:47:31-06:00
summary:

closes gh-99508: fix `TypeError` in `Lib/importlib/_bootstrap_external.py` (GH-99635)

files:
A Misc/NEWS.d/next/Library/2022-11-21-10-45-54.gh-issue-99508.QqVbby.rst
M Lib/importlib/_bootstrap_external.py

diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index f4dbbebcd224..71a16064b8ec 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -1144,7 +1144,8 @@ def get_code(self, fullname):
                 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
index 000000000000..82720d17bcaf
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-11-21-10-45-54.gh-issue-99508.QqVbby.rst
@@ -0,0 +1,2 @@
+Fix ``TypeError`` in ``Lib/importlib/_bootstrap_external.py`` while calling
+``_imp.source_hash()``.



More information about the Python-checkins mailing list