10000 [mypyc] Add internal import for _PyUnicode_CheckConsistency for py 3.… · python/mypy@61b3664 · GitHub
[go: up one dir, main page]

Skip to content

Commit 61b3664

Browse files
authored
[mypyc] Add internal import for _PyUnicode_CheckConsistency for py 3.13 (#19045)
In debug build of Python 3.13, mypyc fails to build due to `_PyUnicode_CheckConsistency` being moved to internal. Let's include this, but only for Python 3.13 and only for debug builds. Technically, the assert doesn't need to be behind a Py_DEBUG, but just in case...
1 parent bd1f51a commit 61b3664

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

mypyc/lib-rt/str_ops.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
#include <Python.h>
66
#include "CPy.h"
77

8+
// The _PyUnicode_CheckConsistency definition has been moved to the internal API
9+
// https://github.com/python/cpython/pull/106398
10+
#if defined(Py_DEBUG) && defined(CPY_3_13_FEATURES)
11+
#include "internal/pycore_unicodeobject.h"
12+
#endif
13+
814
// Copied from cpython.git:Objects/unicodeobject.c@0ef4ffeefd1737c18dc9326133c7894d58108c2e.
915
#define BLOOM_MASK unsigned long
1016
#define BLOOM(mask, ch) ((mask & (1UL << ((ch) & (BLOOM_WIDTH - 1)))))
@@ -182,7 +188,9 @@ PyObject *CPyStr_Build(Py_ssize_t len, ...) {
182188
assert(res_offset == PyUnicode_GET_LENGTH(res));
183189
}
184190

191+
#ifdef Py_DEBUG
185192
assert(_PyUnicode_CheckConsistency(res, 1));
193+
#endif
186194
return res;
187195
}
188196

0 commit comments

Comments
 (0)
0