[Python-checkins] bpo-40302: UTF-32 encoder SWAB4() macro use a|b rather than a+b (GH-19572)

Victor Stinner webhook-mailer at python.org
Fri Apr 17 13:13:39 EDT 2020


https://github.com/python/cpython/commit/d7c657d4b121164caa439253da5266b2e29a1bed
commit: d7c657d4b121164caa439253da5266b2e29a1bed
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-04-17T19:13:34+02:00
summary:

bpo-40302: UTF-32 encoder SWAB4() macro use a|b rather than a+b (GH-19572)

files:
M Objects/stringlib/codecs.h

diff --git a/Objects/stringlib/codecs.h b/Objects/stringlib/codecs.h
index 208e8fe4a48bb..9b2a29ba3b8c2 100644
--- a/Objects/stringlib/codecs.h
+++ b/Objects/stringlib/codecs.h
@@ -743,7 +743,7 @@ STRINGLIB(SWAB4)(STRINGLIB_CHAR ch)
     return (word << 24);
 #elif STRINGLIB_SIZEOF_CHAR == 2
     /* high bytes are zero */
-    return ((word & 0x00FFu) << 24) + ((word & 0xFF00u) << 8);
+    return ((word & 0x00FFu) << 24) | ((word & 0xFF00u) << 8);
 #else
     return _Py_bswap32(word);
 #endif



More information about the Python-checkins mailing list