Skip to content

Commit 72324ab

Browse files
committed
bpo-33407: Implement Py_DEPRECATED() on Windows
1 parent d500e53 commit 72324ab

File tree

11 files changed

+114
-103
lines changed

11 files changed

+114
-103
lines changed

Include/abstract.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -468,39 +468,38 @@ PyAPI_FUNC(int) PyObject_DelItem(PyObject *o, PyObject *key);
468468
469469
Return 0 on success. buffer and buffer_len are only set in case no error
470470
occurs. Otherwise, -1 is returned and an exception set. */
471+
Py_DEPRECATED(3.0)
471472
PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj,
472473
const char **buffer,
473-
Py_ssize_t *buffer_len)
474-
Py_DEPRECATED(3.0);
474+
Py_ssize_t *buffer_len);
475475

476476
/* Checks whether an arbitrary object supports the (character, single segment)
477477
buffer interface.
478478
479479
Returns 1 on success, 0 on failure. */
480-
PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *obj)
481-
Py_DEPRECATED(3.0);
480+
Py_DEPRECATED(3.0) PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *obj);
482481

483482
/* Same as PyObject_AsCharBuffer() except that this API expects (readable,
484483
single segment) buffer interface and returns a pointer to a read-only memory
485484
location which can contain arbitrary data.
486485
487486
0 is returned on success. buffer and buffer_len are only set in case no
488487
error occurs. Otherwise, -1 is returned and an exception set. */
488+
Py_DEPRECATED(3.0)
489489
PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj,
490490
const void **buffer,
491-
Py_ssize_t *buffer_len)
492-
Py_DEPRECATED(3.0);
491+
Py_ssize_t *buffer_len);
493492

494493
/* Takes an arbitrary object which must support the (writable, single segment)
495494
buffer interface and returns a pointer to a writable memory location in
496495
buffer of size 'buffer_len'.
497496
498497
Return 0 on success. buffer and buffer_len are only set in case no error
499498
occurs. Otherwise, -1 is returned and an exception set. */
499+
Py_DEPRECATED(3.0)
500500
PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj,
501501
void **buffer,
502-
Py_ssize_t *buffer_len)
503-
Py_DEPRECATED(3.0);
502+
Py_ssize_t *buffer_len);
504503

505504

506505
/* === New Buffer API ============================================ */

Include/ceval.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ PyAPI_FUNC(void) PyEval_InitThreads(void);
193193
#ifndef Py_LIMITED_API
194194
PyAPI_FUNC(void) _PyEval_FiniThreads(void);
195195
#endif /* !Py_LIMITED_API */
196-
PyAPI_FUNC(void) PyEval_AcquireLock(void) Py_DEPRECATED(3.2);
197-
PyAPI_FUNC(void) PyEval_ReleaseLock(void) /* Py_DEPRECATED(3.2) */;
196+
Py_DEPRECATED(3.2) PyAPI_FUNC(void) PyEval_AcquireLock(void);
197+
/* Py_DEPRECATED(3.2) */ PyAPI_FUNC(void) PyEval_ReleaseLock(void);
198198
PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
199199
PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
200200
PyAPI_FUNC(void) PyEval_ReInitThreads(void);

Include/intrcheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PyAPI_FUNC(void) PyOS_AfterFork_Child(void);
1515
#endif
1616
#endif
1717
/* Deprecated, please use PyOS_AfterFork_Child() instead */
18-
PyAPI_FUNC(void) PyOS_AfterFork(void) Py_DEPRECATED(3.7);
18+
Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyOS_AfterFork(void);
1919

2020
#ifndef Py_LIMITED_API
2121
PyAPI_FUNC(int) _PyOS_IsMainThread(void);

Include/longobject.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ PyAPI_FUNC(long long) PyLong_AsLongLongAndOverflow(PyObject *, int *);
102102

103103
PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int);
104104
#ifndef Py_LIMITED_API
105-
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int) Py_DEPRECATED(3.3);
105+
Py_DEPRECATED(3.3)
106+
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
106107
PyAPI_FUNC(PyObject *) PyLong_FromUnicodeObject(PyObject *u, int base);
107108
PyAPI_FUNC(PyObject *) _PyLong_FromBytes(const char *, Py_ssize_t, int);
108109
#endif

Include/moduleobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);
2525
PyAPI_FUNC(PyObject *) PyModule_GetNameObject(PyObject *);
2626
#endif
2727
PyAPI_FUNC(const char *) PyModule_GetName(PyObject *);
28-
PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *) Py_DEPRECATED(3.2);
28+
Py_DEPRECATED(3.2) PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *);
2929
PyAPI_FUNC(PyObject *) PyModule_GetFilenameObject(PyObject *);
3030
#ifndef Py_LIMITED_API
3131
PyAPI_FUNC(void) _PyModule_Clear(PyObject *);

Include/pyerrors.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,9 @@ PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(
254254
const char *filename /* decoded from the filesystem encoding */
255255
);
256256
#if defined(MS_WINDOWS) && !defined(Py_LIMITED_API)
257+
Py_DEPRECATED(3.3)
257258
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
258-
PyObject *, const Py_UNICODE *) Py_DEPRECATED(3.3);
259+
PyObject *, const Py_UNICODE *);
259260
#endif /* MS_WINDOWS */
260261

261262
PyAPI_FUNC(PyObject *) PyErr_Format(
@@ -288,8 +289,9 @@ PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
288289
);
289290
#ifndef Py_LIMITED_API
290291
/* XXX redeclare to use WSTRING */
292+
Py_DEPRECATED(3.3)
291293
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
292-
int, const Py_UNICODE *) Py_DEPRECATED(3.3);
294+
int, const Py_UNICODE *);
293295
#endif
294296
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);
295297
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(
@@ -304,8 +306,9 @@ PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(
304306
const char *filename /* decoded from the filesystem encoding */
305307
);
306308
#ifndef Py_LIMITED_API
309+
Py_DEPRECATED(3.3)
307310
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
308-
PyObject *,int, const Py_UNICODE *) Py_DEPRECATED(3.3);
311+
PyObject *,int, const Py_UNICODE *);
309312
#endif
310313
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
311314
#endif /* MS_WINDOWS */
@@ -402,25 +405,25 @@ PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create(
402405

403406
/* create a UnicodeEncodeError object */
404407
#ifndef Py_LIMITED_API
405-
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
408+
Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
406409
const char *encoding, /* UTF-8 encoded string */
407410
const Py_UNICODE *object,
408411
Py_ssize_t length,
409412
Py_ssize_t start,
410413
Py_ssize_t end,
411414
const char *reason /* UTF-8 encoded string */
412-
) Py_DEPRECATED(3.3);
415+
);
413416
#endif
414417

415418
/* create a UnicodeTranslateError object */
416419
#ifndef Py_LIMITED_API
417-
PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
420+
Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
418421
const Py_UNICODE *object,
419422
Py_ssize_t length,
420423
Py_ssize_t start,
421424
Py_ssize_t end,
422425
const char *reason /* UTF-8 encoded string */
423-
) Py_DEPRECATED(3.3);
426+
);
424427
PyAPI_FUNC(PyObject *) _PyUnicodeTranslateError_Create(
425428
PyObject *object,
426429
Py_ssize_t start,

Include/pyport.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,13 +484,16 @@ extern "C" {
484484
/* Py_DEPRECATED(version)
485485
* Declare a variable, type, or function deprecated.
486486
* Usage:
487-
* extern int old_var Py_DEPRECATED(2.3);
488-
* typedef int T1 Py_DEPRECATED(2.4);
489-
* extern int x() Py_DEPRECATED(2.5);
487+
* Py_DEPRECATED(2.3) extern int old_var;
488+
* Py_DEPRECATED(2.4) typedef int T1;
489+
* Py_DEPRECATED(2.5) extern int x();
490490
*/
491491
#if defined(__GNUC__) \
492492
&& ((__GNUC__ >= 4) || (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
493493
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
494+
#elif defined(_MSC_VER)
495+
#define Py_DEPRECATED(VERSION) __declspec(deprecated( \
496+
"deprecated in " #VERSION))
494497
#else
495498
#define Py_DEPRECATED(VERSION_UNUSED)
496499
#endif

Include/pythread.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,15 @@ PyAPI_FUNC(PyObject*) PyThread_GetInfo(void);
9292
platforms, but it is not POSIX-compliant. Therefore, the new TSS API uses
9393
opaque data type to represent TSS keys to be compatible (see PEP 539).
9494
*/
95-
PyAPI_FUNC(int) PyThread_create_key(void) Py_DEPRECATED(3.7);
96-
PyAPI_FUNC(void) PyThread_delete_key(int key) Py_DEPRECATED(3.7);
97-
PyAPI_FUNC(int) PyThread_set_key_value(int key, void *value) Py_DEPRECATED(3.7);
98-
PyAPI_FUNC(void *) PyThread_get_key_value(int key) Py_DEPRECATED(3.7);
99-
PyAPI_FUNC(void) PyThread_delete_key_value(int key) Py_DEPRECATED(3.7);
95+
Py_DEPRECATED(3.7) PyAPI_FUNC(int) PyThread_create_key(void);
96+
Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyThread_delete_key(int key);
97+
Py_DEPRECATED(3.7) PyAPI_FUNC(int) PyThread_set_key_value(int key,
98+
void *value);
99+
Py_DEPRECATED(3.7) PyAPI_FUNC(void *) PyThread_get_key_value(int key);
100+
Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyThread_delete_key_value(int key);
100101

101102
/* Cleanup after a fork */
102-
PyAPI_FUNC(void) PyThread_ReInitTLS(void) Py_DEPRECATED(3.7);
103+
Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyThread_ReInitTLS(void);
103104

104105

105106
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000

Include/sliceobject.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ PyAPI_FUNC(int) _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
4040
#endif
4141
PyAPI_FUNC(int) PySlice_GetIndices(PyObject *r, Py_ssize_t length,
4242
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
43+
Py_DEPRECATED(3.7)
4344
PyAPI_FUNC(int) PySlice_GetIndicesEx(PyObject *r, Py_ssize_t length,
4445
Py_ssize_t *start, Py_ssize_t *stop,
45-
Py_ssize_t *step, Py_ssize_t *slicelength) Py_DEPRECATED(3.7);
46+
Py_ssize_t *step,
47+
Py_ssize_t *slicelength);
4648

4749
#if !defined(Py_LIMITED_API) || (Py_LIMITED_API+0 >= 0x03050400 && Py_LIMITED_API+0 < 0x03060000) || Py_LIMITED_API+0 >= 0x03060100
4850
#define PySlice_GetIndicesEx(slice, length, start, stop, step, slicelen) ( \

0 commit comments

Comments
 (0)