Skip to content

Commit 7f9f1b8

Browse files
authored
Add definition for private _PyMem_RawStrdup
Because of python/cpython#107187, _PyMem_RawStrdup is no longer available publicly when including Python.h in Python 3.13 or later.
1 parent 996326c commit 7f9f1b8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

source/legacy/console.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ int wmain(int argc, wchar_t** argv)
6363
return status;
6464
}
6565
#else
66+
static char *
67+
_PyMem_RawStrdup(const char *str)
68+
{
69+
assert(str != NULL);
70+
size_t size = strlen(str) + 1;
71+
char *copy = PyMem_RawMalloc(size);
72+
if (copy == NULL) {
73+
return NULL;
74+
}
75+
memcpy(copy, str, size);
76+
return copy;
77+
}
78+
6679
int main(int argc, char** argv)
6780
{
6881
int status = 0;

0 commit comments

Comments
 (0)