Skip to content

Commit 651fc30

Browse files
bpo-43499: Silence compiler warnings about using legacy C API on Windows (GH-24873)
1 parent a838e47 commit 651fc30

File tree

8 files changed

+42
-0
lines changed

8 files changed

+42
-0
lines changed

Modules/_ctypes/callproc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,10 @@ static PyObject *load_library(PyObject *self, PyObject *args)
13581358
if (!PyArg_ParseTuple(args, "U|i:LoadLibrary", &nameobj, &load_flags))
13591359
return NULL;
13601360

1361+
_Py_COMP_DIAG_PUSH
1362+
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
13611363
name = _PyUnicode_AsUnicode(nameobj);
1364+
_Py_COMP_DIAG_POP
13621365
if (!name)
13631366
return NULL;
13641367

Modules/_io/fileio.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
276276
if (!PyUnicode_FSDecoder(nameobj, &stringobj)) {
277277
return -1;
278278
}
279+
_Py_COMP_DIAG_PUSH
280+
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
279281
widename = PyUnicode_AsUnicode(stringobj);
282+
_Py_COMP_DIAG_POP
280283
if (widename == NULL)
281284
return -1;
282285
#else

Modules/posixmodule.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,10 @@ path_converter(PyObject *o, void *p)
11591159

11601160
if (is_unicode) {
11611161
#ifdef MS_WINDOWS
1162+
_Py_COMP_DIAG_PUSH
1163+
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
11621164
wide = PyUnicode_AsUnicodeAndSize(o, &length);
1165+
_Py_COMP_DIAG_POP
11631166
if (!wide) {
11641167
goto error_exit;
11651168
}
@@ -1250,7 +1253,10 @@ path_converter(PyObject *o, void *p)
12501253
goto error_exit;
12511254
}
12521255

1256+
_Py_COMP_DIAG_PUSH
1257+
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
12531258
wide = PyUnicode_AsUnicodeAndSize(wo, &length);
1259+
_Py_COMP_DIAG_POP
12541260
if (!wide) {
12551261
goto error_exit;
12561262
}
@@ -13238,7 +13244,10 @@ DirEntry_fetch_stat(PyObject *module, DirEntry *self, int follow_symlinks)
1323813244
#ifdef MS_WINDOWS
1323913245
if (!PyUnicode_FSDecoder(self->path, &ub))
1324013246
return NULL;
13247+
_Py_COMP_DIAG_PUSH
13248+
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
1324113249
const wchar_t *path = PyUnicode_AsUnicode(ub);
13250+
_Py_COMP_DIAG_POP
1324213251
#else /* POSIX */
1324313252
if (!PyUnicode_FSConverter(self->path, &ub))
1324413253
return NULL;
@@ -13460,7 +13469,10 @@ os_DirEntry_inode_impl(DirEntry *self)
1346013469

1346113470
if (!PyUnicode_FSDecoder(self->path, &unicode))
1346213471
return NULL;
13472+
_Py_COMP_DIAG_PUSH
13473+
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
1346313474
path = PyUnicode_AsUnicode(unicode);
13475+
_Py_COMP_DIAG_POP
1346413476
result = LSTAT(path, &stat);
1346513477
Py_DECREF(unicode);
1346613478

Objects/unicodeobject.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4321,7 +4321,10 @@ unicode_decode_call_errorhandler_wchar(
43214321
goto onError;
43224322
}
43234323

4324+
_Py_COMP_DIAG_PUSH
4325+
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
43244326
repwstr = PyUnicode_AsUnicodeAndSize(repunicode, &repwlen);
4327+
_Py_COMP_DIAG_POP
43254328
if (repwstr == NULL)
43264329
goto onError;
43274330
/* need more space? (at least enough for what we
@@ -7654,7 +7657,10 @@ encode_code_page_strict(UINT code_page, PyObject **outbytes,
76547657
substring = PyUnicode_Substring(unicode, offset, offset+len);
76557658
if (substring == NULL)
76567659
return -1;
7660+
_Py_COMP_DIAG_PUSH
7661+
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
76577662
p = PyUnicode_AsUnicodeAndSize(substring, &size);
7663+
_Py_COMP_DIAG_POP
76587664
if (p == NULL) {
76597665
Py_DECREF(substring);
76607666
return -1;

PC/_msi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,10 @@ summary_setproperty(msiobj* si, PyObject *args)
625625
return NULL;
626626

627627
if (PyUnicode_Check(data)) {
628+
_Py_COMP_DIAG_PUSH
629+
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
628630
const WCHAR *value = _PyUnicode_AsUnicode(data);
631+
_Py_COMP_DIAG_POP
629632
if (value == NULL) {
630633
return NULL;
631634
}

PC/winreg.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,10 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
646646
t = PyList_GET_ITEM(value, j);
647647
if (!PyUnicode_Check(t))
648648
return FALSE;
649+
_Py_COMP_DIAG_PUSH
650+
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
649651
wstr = PyUnicode_AsUnicodeAndSize(t, &len);
652+
_Py_COMP_DIAG_POP
650653
if (wstr == NULL)
651654
return FALSE;
652655
size += Py_SAFE_DOWNCAST((len + 1) * sizeof(wchar_t),
@@ -669,7 +672,10 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
669672
Py_ssize_t len;
670673

671674
t = PyList_GET_ITEM(value, j);
675+
_Py_COMP_DIAG_PUSH
676+
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
672677
wstr = PyUnicode_AsUnicodeAndSize(t, &len);
678+
_Py_COMP_DIAG_POP
673679
assert(wstr);
674680
wcscpy(P, wstr);
675681
P += (len + 1);

Python/dynload_win.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
170170

171171
_Py_CheckPython3();
172172

173+
_Py_COMP_DIAG_PUSH
174+
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
173175
wpathname = _PyUnicode_AsUnicode(pathname);
176+
_Py_COMP_DIAG_POP
174177
if (wpathname == NULL)
175178
return NULL;
176179

Python/fileutils.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,10 @@ _Py_stat(PyObject *path, struct stat *statbuf)
10101010
struct _stat wstatbuf;
10111011
const wchar_t *wpath;
10121012

1013+
_Py_COMP_DIAG_PUSH
1014+
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
10131015
wpath = _PyUnicode_AsUnicode(path);
1016+
_Py_COMP_DIAG_POP
10141017
if (wpath == NULL)
10151018
return -2;
10161019

@@ -1455,7 +1458,10 @@ _Py_fopen_obj(PyObject *path, const char *mode)
14551458
Py_TYPE(path));
14561459
return NULL;
14571460
}
1461+
_Py_COMP_DIAG_PUSH
1462+
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
14581463
wpath = _PyUnicode_AsUnicode(path);
1464+
_Py_COMP_DIAG_POP
14591465
if (wpath == NULL)
14601466
return NULL;
14611467

0 commit comments

Comments
 (0)