https://github.com/python/cpython/commit/4c23df56f2fc7a6821bedc0a8670338c09d5fab9
commit: 4c23df56f2fc7a6821bedc0a8670338c09d5fab9
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: hugovk <[email protected]>
date: 2026-09-05T15:53:07+01:00
summary:

[3.15] gh-129813: Fix typo in byteswriter_resize() (GH-156938) (#156979)

gh-129813: Fix typo in byteswriter_resize() (GH-156938)

The intent is to test "resize and overallocate", even if in practice
"resize & overallocate" is the same (both variables are either 0 or
1). Use "&&" to better describe the intent of the test.
(cherry picked from commit 5141621d44e8ee88d97a5b8b225c8a32e7a343f0)

Co-authored-by: Victor Stinner <[email protected]>

files:
M Objects/bytesobject.c

diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 33dc66eec629907..5fa20b9f6a4aaaa 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -3629,7 +3629,7 @@ byteswriter_resize(PyBytesWriter *writer, Py_ssize_t 
size, int resize)
         return 0;
     }
 
-    if (resize & writer->overallocate) {
+    if (resize && writer->overallocate) {
         if (size <= (PY_SSIZE_T_MAX - size / OVERALLOCATE_FACTOR)) {
             size += size / OVERALLOCATE_FACTOR;
         }

_______________________________________________
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]

Reply via email to