Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f63dab5

Browse files
committed
Back-out wcstok deprecation suppression and updates calls to use wcstok_s.
1 parent b3f51e3 commit f63dab5

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

Modules/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,16 +520,16 @@ Py_Main(int argc, wchar_t **argv)
520520
#ifdef MS_WINDOWS
521521
if (!Py_IgnoreEnvironmentFlag && (wp = _wgetenv(L"PYTHONWARNINGS")) &&
522522
*wp != L'\0') {
523-
wchar_t *buf, *warning;
523+
wchar_t *buf, *warning, *context = NULL;
524524

525525
buf = (wchar_t *)PyMem_RawMalloc((wcslen(wp) + 1) * sizeof(wchar_t));
526526
if (buf == NULL)
527527
Py_FatalError(
528528
"not enough memory to copy PYTHONWARNINGS");
529529
wcscpy(buf, wp);
530-
for (warning = wcstok(buf, L",");
530+
for (warning = wcstok_s(buf, L",", &context);
531531
warning != NULL;
532-
warning = wcstok(NULL, L",")) {
532+
warning = wcstok_s(NULL, L",", &context)) {
533533
PySys_AddWarnOption(warning);
534534
}
535535
PyMem_RawFree(buf);

PC/getpathp.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,12 @@ find_env_config_value(FILE * env_file, const wchar_t * key, wchar_t * value)
451451
tmpbuffer, MAXPATHLEN * 2);
452452
Py_DECREF(decoded);
453453
if (k >= 0) {
454-
wchar_t * tok = wcstok(tmpbuffer, L" \t\r\n");
454+
wchar_t * context = NULL;
455+
wchar_t * tok = wcstok_s(tmpbuffer, L" \t\r\n", &context);
455456
if ((tok != NULL) && !wcscmp(tok, key)) {
456-
tok = wcstok(NULL, L" \t");
457+
tok = wcstok_s(NULL, L" \t", &context);
457458
if ((tok != NULL) && !wcscmp(tok, L"=")) {
458-
tok = wcstok(NULL, L"\r\n");
459+
tok = wcstok_s(NULL, L"\r\n", &context);
459460
if (tok != NULL) {
460461
wcsncpy(value, tok, MAXPATHLEN);
461462
result = 1;

PCbuild/pythoncore.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<ClCompile>
6868
<AdditionalOptions>/Zm200 %(AdditionalOptions)</AdditionalOptions>
6969
<AdditionalIncludeDirectories>$(PySourcePath)Python;$(PySourcePath)Modules\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
70-
<PreprocessorDefinitions>_CRT_NON_CONFORMING_WCSTOK;_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
70+
<PreprocessorDefinitions>_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
7171
</ClCompile>
7272
<Link>
7373
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>

0 commit comments

Comments
 (0)