Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaraditya303 committed Dec 17, 2024
1 parent ab39b71 commit d24924c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Lib/test/test_capi/test_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d24924c

Please sign in to comment.