From d24924c8a203e9c7b7059a9ba433f40a5ac83462 Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Tue, 17 Dec 2024 09:46:00 +0000 Subject: [PATCH] fix --- Lib/test/test_capi/test_unicode.py | 2 +- Objects/unicodeobject.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_capi/test_unicode.py b/Lib/test/test_capi/test_unicode.py index 0b5e4f7b66508d5..da2d857a8db875d 100644 --- a/Lib/test/test_capi/test_unicode.py +++ b/Lib/test/test_capi/test_unicode.py @@ -1015,7 +1015,7 @@ def test_asutf8_race(self): def worker(): for _ in range(1000): - self.assertEqual(unicode_asutf8(data, 4), b'\xf0\x9f\x98\x8a\0') + self.assertEqual(unicode_asutf8(data, 5), b'\xf0\x9f\x98\x8a\0') threads = [Thread(target=worker) for _ in range(10)] with threading_helper.start_threads(threads): diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index abd79dcaed465e1..8b4c1d24bd08d52 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -118,7 +118,7 @@ NOTE: In the interpreter's initialization phase, some globals are currently (assert(_PyUnicode_CHECK(op)), \ PyUnicode_IS_COMPACT_ASCII(op) ? \ ((char*)(_PyASCIIObject_CAST(op) + 1)) : \ - _PyUnicode_UTF8(op)) + FT_ATOMIC_LOAD_PTR(_PyUnicode_UTF8(op))) #define _PyUnicode_UTF8_LENGTH(op) \ (_PyCompactUnicodeObject_CAST(op)->utf8_length) #define PyUnicode_UTF8_LENGTH(op) \ @@ -4194,7 +4194,7 @@ PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *psize) return NULL; } - if (FT_ATOMIC_LOAD_PTR(PyUnicode_UTF8(unicode)) == NULL) { + if (PyUnicode_UTF8(unicode) == NULL) { if (unicode_fill_utf8(unicode) == -1) { if (psize) { *psize = -1; @@ -5825,7 +5825,7 @@ unicode_fill_utf8(PyObject *unicode) assert(!PyUnicode_IS_ASCII(unicode)); int ret = 0; Py_BEGIN_CRITICAL_SECTION(unicode); - if (FT_ATOMIC_LOAD_PTR(PyUnicode_UTF8(unicode))) { + if (FT_ATOMIC_LOAD_PTR(_PyUnicode_UTF8(unicode))) { goto exit; } int kind = PyUnicode_KIND(unicode);