Skip to content

run_presite's error handling is wrong #115503

@sobolevn

Description

@sobolevn

Bug report

cpython/Python/pylifecycle.c

Lines 1106 to 1113 in 4742047

PyObject *presite_modname = PyUnicode_FromWideChar(
config->run_presite,
wcslen(config->run_presite)
);
if (presite_modname == NULL) {
fprintf(stderr, "Could not convert pre-site module name to unicode\n");
Py_DECREF(presite_modname);
}

I think that Py_DECREF(presite_modname); is not needed, because presite_modname is NULL in this branch.

This will, likely, lead to a crash.
I have a PR ready.

Linked PRs

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions