2 #define PY_SSIZE_T_CLEAN
3 #define _GNU_SOURCE 1 // asprintf
6 // According to Python, its header has to go first:
7 // http://docs.python.org/2/c-api/intro.html#include-files
8 // http://docs.python.org/3/c-api/intro.html#include-files
11 #include "bup/compat.h"
14 #if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 8
16 int bup_py_bytes_main(int argc, char **argv)
18 wchar_t **wargv = PyMem_RawMalloc(argc * sizeof(wchar_t *));
20 die(2, "memory insufficient to decode command line arguments");
22 for (i = 0; i < argc; i++) {
24 wargv[i] = Py_DecodeLocale(argv[i], &wargn);
28 die(2, "too little memory to decode command line argument %d\n",
32 die(2, "unable to decode command line argument %d\n", i);
35 die(2, "unexpected error from Py_DecodeLocale(): %zu\n", wargn);
41 return Py_Main(argc, wargv);
44 #endif // PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 8