From 53147e76fc21a54f58e3fc842b6c1c7eb4a85cba Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Wed, 1 Jan 2025 18:49:17 +0900 Subject: [PATCH] Address code review --- Include/cpython/unicodeobject.h | 16 ++++++++++------ Lib/test/test_str.py | 2 -- Lib/test/test_sys.py | 2 -- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Include/cpython/unicodeobject.h b/Include/cpython/unicodeobject.h index 919251c06eed5e..0dfea8a3940d8e 100644 --- a/Include/cpython/unicodeobject.h +++ b/Include/cpython/unicodeobject.h @@ -132,21 +132,25 @@ typedef struct { * all characters are in the range U+0000-U+10FFFF * at least one character is in the range U+10000-U+10FFFF */ - unsigned int kind:3; + unsigned char kind:3; /* Compact is with respect to the allocation scheme. Compact unicode objects only require one memory block while non-compact objects use one block for the PyUnicodeObject struct and another for its data buffer. */ - unsigned int compact:1; + unsigned char compact:1; /* The string only contains characters in the range U+0000-U+007F (ASCII) and the kind is PyUnicode_1BYTE_KIND. If ascii is set and compact is set, use the PyASCIIObject structure. */ - unsigned int ascii:1; + unsigned char ascii:1; /* The object is statically allocated. */ - unsigned int statically_allocated:1; + unsigned char statically_allocated:1; /* Padding to ensure that PyUnicode_DATA() is always aligned to - 4 bytes (see issue #19537 on m68k). */ - unsigned int :18; + 4 bytes (see issue #19537 on m68k) and we use unsigned char to avoid + the extra four bytes on 32-bit Windows. This is restricted features + for specific compilers including GCC, MSVC, Clang and IBM's XL compiler. */ + unsigned char :2; + unsigned char :8; + unsigned char :8; } state; } PyASCIIObject; diff --git a/Lib/test/test_str.py b/Lib/test/test_str.py index 82be790c52a946..4de6c1cba152bd 100644 --- a/Lib/test/test_str.py +++ b/Lib/test/test_str.py @@ -2450,8 +2450,6 @@ def test_expandtabs_optimization(self): def test_raiseMemError(self): asciifields = "nnb" - if not support.is_wasi: - asciifields = asciifields + "7x" compactfields = asciifields + "nP" ascii_struct_size = support.calcobjsize(asciifields) compact_struct_size = support.calcobjsize(compactfields) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 910c8f291c708f..d839893d2c657e 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1763,8 +1763,6 @@ class newstyleclass(object): pass '\U00010000'*30, '\U0010ffff'*100] # also update field definitions in test_unicode.test_raiseMemError asciifields = "nnb" - if not support.is_wasi: - asciifields = asciifields + "7x" compactfields = asciifields + "nP" unicodefields = compactfields + "P" for s in samples: