Use f-string

This commit is contained in:
Andrew Murray 2024-05-08 17:57:36 +10:00
parent ed0867abec
commit a3356879fd

View File

@ -409,15 +409,14 @@ class TestEmbeddable:
from setuptools.command import build_ext
with open("embed_pil.c", "w", encoding="utf-8") as fh:
home = sys.prefix.replace("\\", "\\\\")
fh.write(
"""
f"""
#include "Python.h"
int main(int argc, char* argv[])
{
char *home = \""""
+ sys.prefix.replace("\\", "\\\\")
+ """\";
{{
char *home = "{home}";
wchar_t *whome = Py_DecodeLocale(home, NULL);
Py_SetPythonHome(whome);
@ -432,7 +431,7 @@ int main(int argc, char* argv[])
PyMem_RawFree(whome);
return 0;
}
}}
"""
)