Skip to content

Commit 070002f

Browse files
authored
Merge pull request #158 from vstinner/fix_clearenv
Fix for CPython 3.15 (clearenv)
2 parents 5c22049 + 68125ab commit 070002f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/spt_setup.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ find_argv_from_env(int argc, char *arg0)
139139
}
140140
buf[argc] = NULL;
141141

142+
/* environ can be NULL if clearenv() has been called.
143+
* Python 3.15 implements os.environ.clear() as clearenv(). */
144+
if (!environ) {
145+
spt_debug("environ pointer is NULL");
146+
goto exit;
147+
}
148+
142149
/* Walk back from environ until you find argc-1 null-terminated strings.
143150
* Don't look for argv[0] as it's probably not preceded by 0. */
144151
ptr = environ[0];

0 commit comments

Comments
 (0)