summaryrefslogtreecommitdiffstats
path: root/Python/preconfig.c
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2021-09-27 16:00:32 (GMT)
committerGitHub <noreply@github.com>2021-09-27 16:00:32 (GMT)
commitae7839bbe817329dd015f9195da308a0f3fbd3e2 (patch)
treeba710c468adef4718e3d1ed9747d2acdc830216b /Python/preconfig.c
parente5f13ce5b48b551c09fdd0faeafa6ecf860de51c (diff)
downloadcpython-ae7839bbe817329dd015f9195da308a0f3fbd3e2.zip
cpython-ae7839bbe817329dd015f9195da308a0f3fbd3e2.tar.gz
cpython-ae7839bbe817329dd015f9195da308a0f3fbd3e2.tar.bz2
bpo-45211: Move helpers from getpath.c to internal API. (gh-28550)
This accomplishes 2 things: * consolidates some common code between getpath.c and getpathp.c * makes the helpers available to code in other files FWIW, the signature of the join_relfile() function (in fileutils.c) intentionally mirrors that of Windows' PathCchCombineEx(). Note that this change is mostly moving code around. No behavior is meant to change. https://bugs.python.org/issue45211
Diffstat (limited to 'Python/preconfig.c')
-rw-r--r--Python/preconfig.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/Python/preconfig.c b/Python/preconfig.c
index ae1cc3f..d592731 100644
--- a/Python/preconfig.c
+++ b/Python/preconfig.c
@@ -1,4 +1,5 @@
#include "Python.h"
+#include "pycore_fileutils.h" // DECODE_LOCALE_ERR
#include "pycore_getopt.h" // _PyOS_GetOpt()
#include "pycore_initconfig.h" // _PyArgv
#include "pycore_pymem.h" // _PyMem_GetAllocatorName()
@@ -6,12 +7,6 @@
#include <locale.h> // setlocale()
-#define DECODE_LOCALE_ERR(NAME, LEN) \
- (((LEN) == -2) \
- ? _PyStatus_ERR("cannot decode " NAME) \
- : _PyStatus_NO_MEMORY())
-
-
/* Forward declarations */
static void
preconfig_copy(PyPreConfig *config, const PyPreConfig *config2);
@@ -87,8 +82,7 @@ _PyArgv_AsWstrList(const _PyArgv *args, PyWideStringList *list)
wchar_t *arg = Py_DecodeLocale(args->bytes_argv[i], &len);
if (arg == NULL) {
_PyWideStringList_Clear(&wargv);
- return DECODE_LOCALE_ERR("command line arguments",
- (Py_ssize_t)len);
+ return DECODE_LOCALE_ERR("command line arguments", len);
}
wargv.items[i] = arg;
wargv.length++;