bpo-36301: Add _PyWstrList structure (GH-12343) · python/cpython@74f6568

@@ -84,15 +84,15 @@ mainconfig_add_xoption(PyObject *opts, const wchar_t *s)

8484

static PyObject*

8585

mainconfig_create_xoptions_dict(const _PyCoreConfig *config)

8686

{

87-

int nxoption = config->nxoption;

88-

wchar_t **xoptions = config->xoptions;

87+

Py_ssize_t nxoption = config->xoptions.length;

88+

wchar_t * const * xoptions = config->xoptions.items;

8989

PyObject *dict = PyDict_New();

9090

if (dict == NULL) {

9191

return NULL;

9292

}

939394-

for (int i=0; i < nxoption; i++) {

95-

wchar_t *option = xoptions[i];

94+

for (Py_ssize_t i=0; i < nxoption; i++) {

95+

const wchar_t *option = xoptions[i];

9696

if (mainconfig_add_xoption(dict, option) < 0) {

9797

Py_DECREF(dict);

9898

return NULL;

@@ -243,22 +243,18 @@ _PyMainInterpreterConfig_Read(_PyMainInterpreterConfig *main_config,

243243

} \

244244

} \

245245

} while (0)

246-

#define COPY_WSTRLIST(ATTR, LEN, LIST) \

246+

#define COPY_WSTRLIST(ATTR, LIST) \

247247

do { \

248248

if (ATTR == NULL) { \

249-

ATTR = _Py_wstrlist_as_pylist(LEN, LIST); \

249+

ATTR = _PyWstrList_AsList(LIST); \

250250

if (ATTR == NULL) { \

251251

return _Py_INIT_NO_MEMORY(); \

252252

} \

253253

} \

254254

} while (0)

255255256-

COPY_WSTRLIST(main_config->warnoptions,

257-

config->nwarnoption, config->warnoptions);

258-

if (config->argc >= 0) {

259-

COPY_WSTRLIST(main_config->argv,

260-

config->argc, config->argv);

261-

}

256+

COPY_WSTRLIST(main_config->warnoptions, &config->warnoptions);

257+

COPY_WSTRLIST(main_config->argv, &config->argv);

262258263259

if (config->_install_importlib) {

264260

COPY_WSTR(executable);

@@ -268,7 +264,7 @@ _PyMainInterpreterConfig_Read(_PyMainInterpreterConfig *main_config,

268264

COPY_WSTR(base_exec_prefix);

269265270266

COPY_WSTRLIST(main_config->module_search_path,

271-

config->nmodule_search_path, config->module_search_paths);

267+

&config->module_search_paths);

272268273269

if (config->pycache_prefix != NULL) {

274270

COPY_WSTR(pycache_prefix);

@@ -784,8 +780,7 @@ pymain_run_python(PyInterpreterState *interp, int *exitcode)

784780

}

785781

}

786782

else if (!config->preconfig.isolated) {

787-

PyObject *path0 = _PyPathConfig_ComputeArgv0(config->argc,

788-

config->argv);

783+

PyObject *path0 = _PyPathConfig_ComputeArgv0(&config->argv);

789784

if (path0 == NULL) {

790785

err = _Py_INIT_NO_MEMORY();

791786

goto done;