https://github.com/python/cpython/commit/353bfc813b9e3b91c718b217ce30f9f0715a5404 commit: 353bfc813b9e3b91c718b217ce30f9f0715a5404 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: serhiy-storchaka <[email protected]> date: 2025-11-07T11:10:21Z summary:
[3.13] gh-141141: Make base64.b85decode() thread safe (GH-141149) (GH-141185) (cherry picked from commit a7bf27f7f521384a8964718bdb58a5cb113bb3ec) Co-authored-by: Benel Tayar <[email protected]> files: A Misc/NEWS.d/next/Library/2025-11-06-15-11-50.gh-issue-141141.tgIfgH.rst M Lib/base64.py diff --git a/Lib/base64.py b/Lib/base64.py index 5a7e790a193380..e8bc252ecfa638 100755 --- a/Lib/base64.py +++ b/Lib/base64.py @@ -465,9 +465,12 @@ def b85decode(b): # Delay the initialization of tables to not waste memory # if the function is never called if _b85dec is None: - _b85dec = [None] * 256 + # we don't assign to _b85dec directly to avoid issues when + # multiple threads call this function simultaneously + b85dec_tmp = [None] * 256 for i, c in enumerate(_b85alphabet): - _b85dec[c] = i + b85dec_tmp[c] = i + _b85dec = b85dec_tmp b = _bytes_from_decode_data(b) padding = (-len(b)) % 5 diff --git a/Misc/NEWS.d/next/Library/2025-11-06-15-11-50.gh-issue-141141.tgIfgH.rst b/Misc/NEWS.d/next/Library/2025-11-06-15-11-50.gh-issue-141141.tgIfgH.rst new file mode 100644 index 00000000000000..f59ccfb33e7669 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-11-06-15-11-50.gh-issue-141141.tgIfgH.rst @@ -0,0 +1 @@ +Fix a thread safety issue with :func:`base64.b85decode`. Contributed by Benel Tayar. _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
