[Python-checkins] bpo-44285: getpath.c: Assert that env_file is NULL during an error check (GH-26486)

encukou webhook-mailer at python.org
Wed Jun 2 10:54:58 EDT 2021


https://github.com/python/cpython/commit/bdb56902a3bfe12b10f85a941d5dd0eae739f1a8
commit: bdb56902a3bfe12b10f85a941d5dd0eae739f1a8
branch: main
author: stratakis <cstratak at redhat.com>
committer: encukou <encukou at gmail.com>
date: 2021-06-02T16:54:33+02:00
summary:

bpo-44285: getpath.c: Assert that env_file is NULL during an error check (GH-26486)

This was flagged by a static analyzer, but the logic of why this is NULL on error is hard to follow for humans as well.

files:
M Modules/getpath.c

diff --git a/Modules/getpath.c b/Modules/getpath.c
index 44453f29df703..363d62a0657eb 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -1263,6 +1263,7 @@ calculate_read_pyenv(PyCalculatePath *calculate)
 
     status = calculate_open_pyenv(calculate, &env_file);
     if (_PyStatus_EXCEPTION(status)) {
+        assert(env_file == NULL);
         return status;
     }
     if (env_file == NULL) {



More information about the Python-checkins mailing list