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