bpo-33407: Implement Py_DEPRECATED() on MSVC (GH-8980)

This commit is contained in:
Zackery Spytz 2019-05-28 09:16:33 -06:00 committed by Victor Stinner
parent 17a5588740
commit 3c8724fc60
14 changed files with 136 additions and 104 deletions

View File

@ -160,6 +160,18 @@ complete listing.
.. versionadded:: 3.4 .. versionadded:: 3.4
.. c:macro:: Py_DEPRECATED(version)
Use this for deprecated declarations. The macro must be placed before the
symbol name.
Example::
Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void);
.. versionchanged:: 3.8
MSVC support was added.
.. _api-objects: .. _api-objects:

View File

@ -1240,6 +1240,15 @@ Changes in the C API
(Contributed by Eddie Elizondo in :issue:`35810`.) (Contributed by Eddie Elizondo in :issue:`35810`.)
* The :c:macro:`Py_DEPRECATED()` macro has been implemented for MSVC.
The macro now must be placed before the symbol name.
Example::
Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void);
(Contributed by Zackery Spytz in :issue:`33407`.)
CPython bytecode changes CPython bytecode changes
------------------------ ------------------------

View File

@ -316,17 +316,16 @@ PyAPI_FUNC(int) PyObject_DelItem(PyObject *o, PyObject *key);
Return 0 on success. buffer and buffer_len are only set in case no error Return 0 on success. buffer and buffer_len are only set in case no error
occurs. Otherwise, -1 is returned and an exception set. */ occurs. Otherwise, -1 is returned and an exception set. */
Py_DEPRECATED(3.0)
PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj, PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj,
const char **buffer, const char **buffer,
Py_ssize_t *buffer_len) Py_ssize_t *buffer_len);
Py_DEPRECATED(3.0);
/* Checks whether an arbitrary object supports the (character, single segment) /* Checks whether an arbitrary object supports the (character, single segment)
buffer interface. buffer interface.
Returns 1 on success, 0 on failure. */ Returns 1 on success, 0 on failure. */
PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *obj) Py_DEPRECATED(3.0) PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *obj);
Py_DEPRECATED(3.0);
/* Same as PyObject_AsCharBuffer() except that this API expects (readable, /* Same as PyObject_AsCharBuffer() except that this API expects (readable,
single segment) buffer interface and returns a pointer to a read-only memory single segment) buffer interface and returns a pointer to a read-only memory
@ -334,10 +333,10 @@ PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *obj)
0 is returned on success. buffer and buffer_len are only set in case no 0 is returned on success. buffer and buffer_len are only set in case no
error occurs. Otherwise, -1 is returned and an exception set. */ error occurs. Otherwise, -1 is returned and an exception set. */
Py_DEPRECATED(3.0)
PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj, PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj,
const void **buffer, const void **buffer,
Py_ssize_t *buffer_len) Py_ssize_t *buffer_len);
Py_DEPRECATED(3.0);
/* Takes an arbitrary object which must support the (writable, single segment) /* Takes an arbitrary object which must support the (writable, single segment)
buffer interface and returns a pointer to a writable memory location in buffer interface and returns a pointer to a writable memory location in
@ -345,10 +344,10 @@ PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj,
Return 0 on success. buffer and buffer_len are only set in case no error Return 0 on success. buffer and buffer_len are only set in case no error
occurs. Otherwise, -1 is returned and an exception set. */ occurs. Otherwise, -1 is returned and an exception set. */
Py_DEPRECATED(3.0)
PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj, PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj,
void **buffer, void **buffer,
Py_ssize_t *buffer_len) Py_ssize_t *buffer_len);
Py_DEPRECATED(3.0);
/* === New Buffer API ============================================ */ /* === New Buffer API ============================================ */

View File

@ -189,8 +189,8 @@ PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);
PyAPI_FUNC(int) PyEval_ThreadsInitialized(void); PyAPI_FUNC(int) PyEval_ThreadsInitialized(void);
PyAPI_FUNC(void) PyEval_InitThreads(void); PyAPI_FUNC(void) PyEval_InitThreads(void);
PyAPI_FUNC(void) PyEval_AcquireLock(void) Py_DEPRECATED(3.2); Py_DEPRECATED(3.2) PyAPI_FUNC(void) PyEval_AcquireLock(void);
PyAPI_FUNC(void) PyEval_ReleaseLock(void) /* Py_DEPRECATED(3.2) */; /* Py_DEPRECATED(3.2) */ PyAPI_FUNC(void) PyEval_ReleaseLock(void);
PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate); PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate); PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);

View File

@ -88,8 +88,9 @@ PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);
/* Convenience functions */ /* Convenience functions */
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
Py_DEPRECATED(3.3)
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename( PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
PyObject *, const Py_UNICODE *) Py_DEPRECATED(3.3); PyObject *, const Py_UNICODE *);
#endif /* MS_WINDOWS */ #endif /* MS_WINDOWS */
/* Like PyErr_Format(), but saves current exception as __context__ and /* Like PyErr_Format(), but saves current exception as __context__ and
@ -103,11 +104,12 @@ PyAPI_FUNC(PyObject *) _PyErr_FormatFromCause(
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
/* XXX redeclare to use WSTRING */ /* XXX redeclare to use WSTRING */
Py_DEPRECATED(3.3)
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename( PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
int, const Py_UNICODE *) Py_DEPRECATED(3.3); int, const Py_UNICODE *);
Py_DEPRECATED(3.3)
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename( PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
PyObject *,int, const Py_UNICODE *) Py_DEPRECATED(3.3); PyObject *,int, const Py_UNICODE *);
#endif #endif
/* In exceptions.c */ /* In exceptions.c */
@ -147,23 +149,23 @@ PyAPI_FUNC(PyObject *) PyErr_ProgramTextObject(
int lineno); int lineno);
/* Create a UnicodeEncodeError object */ /* Create a UnicodeEncodeError object */
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create( Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
const char *encoding, /* UTF-8 encoded string */ const char *encoding, /* UTF-8 encoded string */
const Py_UNICODE *object, const Py_UNICODE *object,
Py_ssize_t length, Py_ssize_t length,
Py_ssize_t start, Py_ssize_t start,
Py_ssize_t end, Py_ssize_t end,
const char *reason /* UTF-8 encoded string */ const char *reason /* UTF-8 encoded string */
) Py_DEPRECATED(3.3); );
/* Create a UnicodeTranslateError object */ /* Create a UnicodeTranslateError object */
PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create( Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
const Py_UNICODE *object, const Py_UNICODE *object,
Py_ssize_t length, Py_ssize_t length,
Py_ssize_t start, Py_ssize_t start,
Py_ssize_t end, Py_ssize_t end,
const char *reason /* UTF-8 encoded string */ const char *reason /* UTF-8 encoded string */
) Py_DEPRECATED(3.3); );
PyAPI_FUNC(PyObject *) _PyUnicodeTranslateError_Create( PyAPI_FUNC(PyObject *) _PyUnicodeTranslateError_Create(
PyObject *object, PyObject *object,
Py_ssize_t start, Py_ssize_t start,

View File

@ -11,7 +11,7 @@ extern "C" {
With PEP 393, Py_UNICODE is deprecated and replaced with a With PEP 393, Py_UNICODE is deprecated and replaced with a
typedef to wchar_t. */ typedef to wchar_t. */
#define PY_UNICODE_TYPE wchar_t #define PY_UNICODE_TYPE wchar_t
typedef wchar_t Py_UNICODE /* Py_DEPRECATED(3.3) */; /* Py_DEPRECATED(3.3) */ typedef wchar_t Py_UNICODE;
/* --- Internal Unicode Operations ---------------------------------------- */ /* --- Internal Unicode Operations ---------------------------------------- */
@ -257,6 +257,7 @@ typedef struct {
If the Py_UNICODE representation is not available, it will be computed If the Py_UNICODE representation is not available, it will be computed
on request. Use PyUnicode_GET_LENGTH() for the length in code points. */ on request. Use PyUnicode_GET_LENGTH() for the length in code points. */
/* Py_DEPRECATED(3.3) */
#define PyUnicode_GET_SIZE(op) \ #define PyUnicode_GET_SIZE(op) \
(assert(PyUnicode_Check(op)), \ (assert(PyUnicode_Check(op)), \
(((PyASCIIObject *)(op))->wstr) ? \ (((PyASCIIObject *)(op))->wstr) ? \
@ -264,26 +265,25 @@ typedef struct {
((void)PyUnicode_AsUnicode(_PyObject_CAST(op)),\ ((void)PyUnicode_AsUnicode(_PyObject_CAST(op)),\
assert(((PyASCIIObject *)(op))->wstr), \ assert(((PyASCIIObject *)(op))->wstr), \
PyUnicode_WSTR_LENGTH(op))) PyUnicode_WSTR_LENGTH(op)))
/* Py_DEPRECATED(3.3) */
/* Py_DEPRECATED(3.3) */
#define PyUnicode_GET_DATA_SIZE(op) \ #define PyUnicode_GET_DATA_SIZE(op) \
(PyUnicode_GET_SIZE(op) * Py_UNICODE_SIZE) (PyUnicode_GET_SIZE(op) * Py_UNICODE_SIZE)
/* Py_DEPRECATED(3.3) */
/* Alias for PyUnicode_AsUnicode(). This will create a wchar_t/Py_UNICODE /* Alias for PyUnicode_AsUnicode(). This will create a wchar_t/Py_UNICODE
representation on demand. Using this macro is very inefficient now, representation on demand. Using this macro is very inefficient now,
try to port your code to use the new PyUnicode_*BYTE_DATA() macros or try to port your code to use the new PyUnicode_*BYTE_DATA() macros or
use PyUnicode_WRITE() and PyUnicode_READ(). */ use PyUnicode_WRITE() and PyUnicode_READ(). */
/* Py_DEPRECATED(3.3) */
#define PyUnicode_AS_UNICODE(op) \ #define PyUnicode_AS_UNICODE(op) \
(assert(PyUnicode_Check(op)), \ (assert(PyUnicode_Check(op)), \
(((PyASCIIObject *)(op))->wstr) ? (((PyASCIIObject *)(op))->wstr) : \ (((PyASCIIObject *)(op))->wstr) ? (((PyASCIIObject *)(op))->wstr) : \
PyUnicode_AsUnicode(_PyObject_CAST(op))) PyUnicode_AsUnicode(_PyObject_CAST(op)))
/* Py_DEPRECATED(3.3) */
/* Py_DEPRECATED(3.3) */
#define PyUnicode_AS_DATA(op) \ #define PyUnicode_AS_DATA(op) \
((const char *)(PyUnicode_AS_UNICODE(op))) ((const char *)(PyUnicode_AS_UNICODE(op)))
/* Py_DEPRECATED(3.3) */
/* --- Flexible String Representation Helper Macros (PEP 393) -------------- */ /* --- Flexible String Representation Helper Macros (PEP 393) -------------- */
@ -543,10 +543,10 @@ PyAPI_FUNC(void) _PyUnicode_FastFill(
only allowed if u was set to NULL. only allowed if u was set to NULL.
The buffer is copied into the new object. */ The buffer is copied into the new object. */
PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode( /* Py_DEPRECATED(3.3) */ PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode(
const Py_UNICODE *u, /* Unicode buffer */ const Py_UNICODE *u, /* Unicode buffer */
Py_ssize_t size /* size of buffer */ Py_ssize_t size /* size of buffer */
) /* Py_DEPRECATED(3.3) */; );
/* Create a new string from a buffer of Py_UCS1, Py_UCS2 or Py_UCS4 characters. /* Create a new string from a buffer of Py_UCS1, Py_UCS2 or Py_UCS4 characters.
Scan the string to find the maximum character. */ Scan the string to find the maximum character. */
@ -572,9 +572,9 @@ PyAPI_FUNC(Py_UCS4) _PyUnicode_FindMaxChar (
Py_UNICODE buffer. Py_UNICODE buffer.
If the wchar_t/Py_UNICODE representation is not yet available, this If the wchar_t/Py_UNICODE representation is not yet available, this
function will calculate it. */ function will calculate it. */
PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode( /* Py_DEPRECATED(3.3) */ PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
PyObject *unicode /* Unicode object */ PyObject *unicode /* Unicode object */
) /* Py_DEPRECATED(3.3) */; );
/* Similar to PyUnicode_AsUnicode(), but raises a ValueError if the string /* Similar to PyUnicode_AsUnicode(), but raises a ValueError if the string
contains null characters. */ contains null characters. */
@ -587,13 +587,13 @@ PyAPI_FUNC(const Py_UNICODE *) _PyUnicode_AsUnicode(
If the wchar_t/Py_UNICODE representation is not yet available, this If the wchar_t/Py_UNICODE representation is not yet available, this
function will calculate it. */ function will calculate it. */
PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicodeAndSize( /* Py_DEPRECATED(3.3) */ PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicodeAndSize(
PyObject *unicode, /* Unicode object */ PyObject *unicode, /* Unicode object */
Py_ssize_t *size /* location where to save the length */ Py_ssize_t *size /* location where to save the length */
) /* Py_DEPRECATED(3.3) */; );
/* Get the maximum ordinal for a Unicode character. */ /* Get the maximum ordinal for a Unicode character. */
PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void) Py_DEPRECATED(3.3); Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void);
/* --- _PyUnicodeWriter API ----------------------------------------------- */ /* --- _PyUnicodeWriter API ----------------------------------------------- */
@ -784,22 +784,22 @@ PyAPI_FUNC(const char *) PyUnicode_AsUTF8(PyObject *unicode);
/* Encodes a Py_UNICODE buffer of the given size and returns a /* Encodes a Py_UNICODE buffer of the given size and returns a
Python string object. */ Python string object. */
PyAPI_FUNC(PyObject*) PyUnicode_Encode( Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_Encode(
const Py_UNICODE *s, /* Unicode char buffer */ const Py_UNICODE *s, /* Unicode char buffer */
Py_ssize_t size, /* number of Py_UNICODE chars to encode */ Py_ssize_t size, /* number of Py_UNICODE chars to encode */
const char *encoding, /* encoding */ const char *encoding, /* encoding */
const char *errors /* error handling */ const char *errors /* error handling */
) Py_DEPRECATED(3.3); );
/* --- UTF-7 Codecs ------------------------------------------------------- */ /* --- UTF-7 Codecs ------------------------------------------------------- */
PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7( Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7(
const Py_UNICODE *data, /* Unicode char buffer */ const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */ Py_ssize_t length, /* number of Py_UNICODE chars to encode */
int base64SetO, /* Encode RFC2152 Set O characters in base64 */ int base64SetO, /* Encode RFC2152 Set O characters in base64 */
int base64WhiteSpace, /* Encode whitespace (sp, ht, nl, cr) in base64 */ int base64WhiteSpace, /* Encode whitespace (sp, ht, nl, cr) in base64 */
const char *errors /* error handling */ const char *errors /* error handling */
) Py_DEPRECATED(3.3); );
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF7( PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF7(
PyObject *unicode, /* Unicode object */ PyObject *unicode, /* Unicode object */
@ -814,20 +814,20 @@ PyAPI_FUNC(PyObject*) _PyUnicode_AsUTF8String(
PyObject *unicode, PyObject *unicode,
const char *errors); const char *errors);
PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8( Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8(
const Py_UNICODE *data, /* Unicode char buffer */ const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */ Py_ssize_t length, /* number of Py_UNICODE chars to encode */
const char *errors /* error handling */ const char *errors /* error handling */
) Py_DEPRECATED(3.3); );
/* --- UTF-32 Codecs ------------------------------------------------------ */ /* --- UTF-32 Codecs ------------------------------------------------------ */
PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF32( Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF32(
const Py_UNICODE *data, /* Unicode char buffer */ const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */ Py_ssize_t length, /* number of Py_UNICODE chars to encode */
const char *errors, /* error handling */ const char *errors, /* error handling */
int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */ int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
) Py_DEPRECATED(3.3); );
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF32( PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF32(
PyObject *object, /* Unicode object */ PyObject *object, /* Unicode object */
@ -856,12 +856,12 @@ PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF32(
at a later point without compromising the APIs. at a later point without compromising the APIs.
*/ */
PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16( Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16(
const Py_UNICODE *data, /* Unicode char buffer */ const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */ Py_ssize_t length, /* number of Py_UNICODE chars to encode */
const char *errors, /* error handling */ const char *errors, /* error handling */
int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */ int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
) Py_DEPRECATED(3.3); );
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF16( PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF16(
PyObject* unicode, /* Unicode object */ PyObject* unicode, /* Unicode object */
@ -882,17 +882,17 @@ PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscape(
string. */ string. */
); );
PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape( Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape(
const Py_UNICODE *data, /* Unicode char buffer */ const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length /* Number of Py_UNICODE chars to encode */ Py_ssize_t length /* Number of Py_UNICODE chars to encode */
) Py_DEPRECATED(3.3); );
/* --- Raw-Unicode-Escape Codecs ------------------------------------------ */ /* --- Raw-Unicode-Escape Codecs ------------------------------------------ */
PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape( Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape(
const Py_UNICODE *data, /* Unicode char buffer */ const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length /* Number of Py_UNICODE chars to encode */ Py_ssize_t length /* Number of Py_UNICODE chars to encode */
) Py_DEPRECATED(3.3); );
/* --- Latin-1 Codecs ----------------------------------------------------- */ /* --- Latin-1 Codecs ----------------------------------------------------- */
@ -900,11 +900,11 @@ PyAPI_FUNC(PyObject*) _PyUnicode_AsLatin1String(
PyObject* unicode, PyObject* unicode,
const char* errors); const char* errors);
PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1( Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1(
const Py_UNICODE *data, /* Unicode char buffer */ const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
const char *errors /* error handling */ const char *errors /* error handling */
) Py_DEPRECATED(3.3); );
/* --- ASCII Codecs ------------------------------------------------------- */ /* --- ASCII Codecs ------------------------------------------------------- */
@ -912,20 +912,20 @@ PyAPI_FUNC(PyObject*) _PyUnicode_AsASCIIString(
PyObject* unicode, PyObject* unicode,
const char* errors); const char* errors);
PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII( Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII(
const Py_UNICODE *data, /* Unicode char buffer */ const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
const char *errors /* error handling */ const char *errors /* error handling */
) Py_DEPRECATED(3.3); );
/* --- Character Map Codecs ----------------------------------------------- */ /* --- Character Map Codecs ----------------------------------------------- */
PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap( Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap(
const Py_UNICODE *data, /* Unicode char buffer */ const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
PyObject *mapping, /* encoding mapping */ PyObject *mapping, /* encoding mapping */
const char *errors /* error handling */ const char *errors /* error handling */
) Py_DEPRECATED(3.3); );
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeCharmap( PyAPI_FUNC(PyObject*) _PyUnicode_EncodeCharmap(
PyObject *unicode, /* Unicode object */ PyObject *unicode, /* Unicode object */
@ -945,21 +945,21 @@ PyAPI_FUNC(PyObject*) _PyUnicode_EncodeCharmap(
are copied as-is. are copied as-is.
*/ */
PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap( Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap(
const Py_UNICODE *data, /* Unicode char buffer */ const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
PyObject *table, /* Translate table */ PyObject *table, /* Translate table */
const char *errors /* error handling */ const char *errors /* error handling */
) Py_DEPRECATED(3.3); );
/* --- MBCS codecs for Windows -------------------------------------------- */ /* --- MBCS codecs for Windows -------------------------------------------- */
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS( Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS(
const Py_UNICODE *data, /* Unicode char buffer */ const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */ Py_ssize_t length, /* number of Py_UNICODE chars to encode */
const char *errors /* error handling */ const char *errors /* error handling */
) Py_DEPRECATED(3.3); );
#endif #endif
/* --- Decimal Encoder ---------------------------------------------------- */ /* --- Decimal Encoder ---------------------------------------------------- */
@ -986,12 +986,12 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS(
*/ */
PyAPI_FUNC(int) PyUnicode_EncodeDecimal( /* Py_DEPRECATED(3.3) */ PyAPI_FUNC(int) PyUnicode_EncodeDecimal(
Py_UNICODE *s, /* Unicode buffer */ Py_UNICODE *s, /* Unicode buffer */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
char *output, /* Output buffer; must have size >= length */ char *output, /* Output buffer; must have size >= length */
const char *errors /* error handling */ const char *errors /* error handling */
) /* Py_DEPRECATED(3.3) */; );
/* Transforms code points that have decimal digit property to the /* Transforms code points that have decimal digit property to the
corresponding ASCII digit code points. corresponding ASCII digit code points.
@ -999,10 +999,11 @@ PyAPI_FUNC(int) PyUnicode_EncodeDecimal(
Returns a new Unicode string on success, NULL on failure. Returns a new Unicode string on success, NULL on failure.
*/ */
/* Py_DEPRECATED(3.3) */
PyAPI_FUNC(PyObject*) PyUnicode_TransformDecimalToASCII( PyAPI_FUNC(PyObject*) PyUnicode_TransformDecimalToASCII(
Py_UNICODE *s, /* Unicode buffer */ Py_UNICODE *s, /* Unicode buffer */
Py_ssize_t length /* Number of Py_UNICODE chars to transform */ Py_ssize_t length /* Number of Py_UNICODE chars to transform */
) /* Py_DEPRECATED(3.3) */; );
/* Coverts a Unicode object holding a decimal value to an ASCII string /* Coverts a Unicode object holding a decimal value to an ASCII string
for using in int, float and complex parsers. for using in int, float and complex parsers.
@ -1101,17 +1102,17 @@ PyAPI_FUNC(int) _PyUnicode_IsLinebreak(
const Py_UCS4 ch /* Unicode character */ const Py_UCS4 ch /* Unicode character */
); );
PyAPI_FUNC(Py_UCS4) _PyUnicode_ToLowercase( /* Py_DEPRECATED(3.3) */ PyAPI_FUNC(Py_UCS4) _PyUnicode_ToLowercase(
Py_UCS4 ch /* Unicode character */ Py_UCS4 ch /* Unicode character */
) /* Py_DEPRECATED(3.3) */; );
PyAPI_FUNC(Py_UCS4) _PyUnicode_ToUppercase( /* Py_DEPRECATED(3.3) */ PyAPI_FUNC(Py_UCS4) _PyUnicode_ToUppercase(
Py_UCS4 ch /* Unicode character */ Py_UCS4 ch /* Unicode character */
) /* Py_DEPRECATED(3.3) */; );
PyAPI_FUNC(Py_UCS4) _PyUnicode_ToTitlecase( Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UCS4) _PyUnicode_ToTitlecase(
Py_UCS4 ch /* Unicode character */ Py_UCS4 ch /* Unicode character */
) Py_DEPRECATED(3.3); );
PyAPI_FUNC(int) _PyUnicode_ToLowerFull( PyAPI_FUNC(int) _PyUnicode_ToLowerFull(
Py_UCS4 ch, /* Unicode character */ Py_UCS4 ch, /* Unicode character */
@ -1173,42 +1174,42 @@ PyAPI_FUNC(int) _PyUnicode_IsAlpha(
Py_UCS4 ch /* Unicode character */ Py_UCS4 ch /* Unicode character */
); );
PyAPI_FUNC(size_t) Py_UNICODE_strlen( Py_DEPRECATED(3.3) PyAPI_FUNC(size_t) Py_UNICODE_strlen(
const Py_UNICODE *u const Py_UNICODE *u
) Py_DEPRECATED(3.3); );
PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strcpy( Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strcpy(
Py_UNICODE *s1, Py_UNICODE *s1,
const Py_UNICODE *s2) Py_DEPRECATED(3.3); const Py_UNICODE *s2);
PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strcat( Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strcat(
Py_UNICODE *s1, const Py_UNICODE *s2) Py_DEPRECATED(3.3); Py_UNICODE *s1, const Py_UNICODE *s2);
PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strncpy( Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strncpy(
Py_UNICODE *s1, Py_UNICODE *s1,
const Py_UNICODE *s2, const Py_UNICODE *s2,
size_t n) Py_DEPRECATED(3.3); size_t n);
PyAPI_FUNC(int) Py_UNICODE_strcmp( Py_DEPRECATED(3.3) PyAPI_FUNC(int) Py_UNICODE_strcmp(
const Py_UNICODE *s1, const Py_UNICODE *s1,
const Py_UNICODE *s2 const Py_UNICODE *s2
) Py_DEPRECATED(3.3); );
PyAPI_FUNC(int) Py_UNICODE_strncmp( Py_DEPRECATED(3.3) PyAPI_FUNC(int) Py_UNICODE_strncmp(
const Py_UNICODE *s1, const Py_UNICODE *s1,
const Py_UNICODE *s2, const Py_UNICODE *s2,
size_t n size_t n
) Py_DEPRECATED(3.3); );
PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strchr( Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strchr(
const Py_UNICODE *s, const Py_UNICODE *s,
Py_UNICODE c Py_UNICODE c
) Py_DEPRECATED(3.3); );
PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strrchr( Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strrchr(
const Py_UNICODE *s, const Py_UNICODE *s,
Py_UNICODE c Py_UNICODE c
) Py_DEPRECATED(3.3); );
PyAPI_FUNC(PyObject*) _PyUnicode_FormatLong(PyObject *, int, int, int); PyAPI_FUNC(PyObject*) _PyUnicode_FormatLong(PyObject *, int, int, int);
@ -1216,9 +1217,9 @@ PyAPI_FUNC(PyObject*) _PyUnicode_FormatLong(PyObject *, int, int, int);
and raise a MemoryError exception on memory allocation failure, otherwise and raise a MemoryError exception on memory allocation failure, otherwise
return a new allocated buffer (use PyMem_Free() to free the buffer). */ return a new allocated buffer (use PyMem_Free() to free the buffer). */
PyAPI_FUNC(Py_UNICODE*) PyUnicode_AsUnicodeCopy( Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) PyUnicode_AsUnicodeCopy(
PyObject *unicode PyObject *unicode
) Py_DEPRECATED(3.3); );
/* Return an interned Unicode object for an Identifier; may fail if there is no memory.*/ /* Return an interned Unicode object for an Identifier; may fail if there is no memory.*/
PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*); PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*);

View File

@ -15,7 +15,7 @@ PyAPI_FUNC(void) PyOS_AfterFork_Child(void);
#endif #endif
#endif #endif
/* Deprecated, please use PyOS_AfterFork_Child() instead */ /* Deprecated, please use PyOS_AfterFork_Child() instead */
PyAPI_FUNC(void) PyOS_AfterFork(void) Py_DEPRECATED(3.7); Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyOS_AfterFork(void);
#ifndef Py_LIMITED_API #ifndef Py_LIMITED_API
PyAPI_FUNC(int) _PyOS_IsMainThread(void); PyAPI_FUNC(int) _PyOS_IsMainThread(void);

View File

@ -102,7 +102,8 @@ PyAPI_FUNC(long long) PyLong_AsLongLongAndOverflow(PyObject *, int *);
PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int); PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int);
#ifndef Py_LIMITED_API #ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int) Py_DEPRECATED(3.3); Py_DEPRECATED(3.3)
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
PyAPI_FUNC(PyObject *) PyLong_FromUnicodeObject(PyObject *u, int base); PyAPI_FUNC(PyObject *) PyLong_FromUnicodeObject(PyObject *u, int base);
PyAPI_FUNC(PyObject *) _PyLong_FromBytes(const char *, Py_ssize_t, int); PyAPI_FUNC(PyObject *) _PyLong_FromBytes(const char *, Py_ssize_t, int);
#endif #endif

View File

@ -25,7 +25,7 @@ PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);
PyAPI_FUNC(PyObject *) PyModule_GetNameObject(PyObject *); PyAPI_FUNC(PyObject *) PyModule_GetNameObject(PyObject *);
#endif #endif
PyAPI_FUNC(const char *) PyModule_GetName(PyObject *); PyAPI_FUNC(const char *) PyModule_GetName(PyObject *);
PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *) Py_DEPRECATED(3.2); Py_DEPRECATED(3.2) PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *);
PyAPI_FUNC(PyObject *) PyModule_GetFilenameObject(PyObject *); PyAPI_FUNC(PyObject *) PyModule_GetFilenameObject(PyObject *);
#ifndef Py_LIMITED_API #ifndef Py_LIMITED_API
PyAPI_FUNC(void) _PyModule_Clear(PyObject *); PyAPI_FUNC(void) _PyModule_Clear(PyObject *);

View File

@ -504,14 +504,18 @@ extern "C" {
/* Py_DEPRECATED(version) /* Py_DEPRECATED(version)
* Declare a variable, type, or function deprecated. * Declare a variable, type, or function deprecated.
* The macro must be placed before the declaration.
* Usage: * Usage:
* extern int old_var Py_DEPRECATED(2.3); * Py_DEPRECATED(3.3) extern int old_var;
* typedef int T1 Py_DEPRECATED(2.4); * Py_DEPRECATED(3.4) typedef int T1;
* extern int x() Py_DEPRECATED(2.5); * Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void);
*/ */
#if defined(__GNUC__) \ #if defined(__GNUC__) \
&& ((__GNUC__ >= 4) || (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) && ((__GNUC__ >= 4) || (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__)) #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
#elif defined(_MSC_VER)
#define Py_DEPRECATED(VERSION) __declspec(deprecated( \
"deprecated in " #VERSION))
#else #else
#define Py_DEPRECATED(VERSION_UNUSED) #define Py_DEPRECATED(VERSION_UNUSED)
#endif #endif

View File

@ -97,14 +97,15 @@ PyAPI_FUNC(PyObject*) PyThread_GetInfo(void);
platforms, but it is not POSIX-compliant. Therefore, the new TSS API uses platforms, but it is not POSIX-compliant. Therefore, the new TSS API uses
opaque data type to represent TSS keys to be compatible (see PEP 539). opaque data type to represent TSS keys to be compatible (see PEP 539).
*/ */
PyAPI_FUNC(int) PyThread_create_key(void) Py_DEPRECATED(3.7); Py_DEPRECATED(3.7) PyAPI_FUNC(int) PyThread_create_key(void);
PyAPI_FUNC(void) PyThread_delete_key(int key) Py_DEPRECATED(3.7); Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyThread_delete_key(int key);
PyAPI_FUNC(int) PyThread_set_key_value(int key, void *value) Py_DEPRECATED(3.7); Py_DEPRECATED(3.7) PyAPI_FUNC(int) PyThread_set_key_value(int key,
PyAPI_FUNC(void *) PyThread_get_key_value(int key) Py_DEPRECATED(3.7); void *value);
PyAPI_FUNC(void) PyThread_delete_key_value(int key) Py_DEPRECATED(3.7); Py_DEPRECATED(3.7) PyAPI_FUNC(void *) PyThread_get_key_value(int key);
Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyThread_delete_key_value(int key);
/* Cleanup after a fork */ /* Cleanup after a fork */
PyAPI_FUNC(void) PyThread_ReInitTLS(void) Py_DEPRECATED(3.7); Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyThread_ReInitTLS(void);
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000

View File

@ -40,9 +40,11 @@ PyAPI_FUNC(int) _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
#endif #endif
PyAPI_FUNC(int) PySlice_GetIndices(PyObject *r, Py_ssize_t length, PyAPI_FUNC(int) PySlice_GetIndices(PyObject *r, Py_ssize_t length,
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step); Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
Py_DEPRECATED(3.7)
PyAPI_FUNC(int) PySlice_GetIndicesEx(PyObject *r, Py_ssize_t length, PyAPI_FUNC(int) PySlice_GetIndicesEx(PyObject *r, Py_ssize_t length,
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *start, Py_ssize_t *stop,
Py_ssize_t *step, Py_ssize_t *slicelength) Py_DEPRECATED(3.7); Py_ssize_t *step,
Py_ssize_t *slicelength);
#if !defined(Py_LIMITED_API) || (Py_LIMITED_API+0 >= 0x03050400 && Py_LIMITED_API+0 < 0x03060000) || Py_LIMITED_API+0 >= 0x03060100 #if !defined(Py_LIMITED_API) || (Py_LIMITED_API+0 >= 0x03050400 && Py_LIMITED_API+0 < 0x03060000) || Py_LIMITED_API+0 >= 0x03060100
#define PySlice_GetIndicesEx(slice, length, start, stop, step, slicelen) ( \ #define PySlice_GetIndicesEx(slice, length, start, stop, step, slicelen) ( \

View File

@ -174,9 +174,9 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_GetLength(
/* Get the number of Py_UNICODE units in the /* Get the number of Py_UNICODE units in the
string representation. */ string representation. */
PyAPI_FUNC(Py_ssize_t) PyUnicode_GetSize( Py_DEPRECATED(3.3) PyAPI_FUNC(Py_ssize_t) PyUnicode_GetSize(
PyObject *unicode /* Unicode object */ PyObject *unicode /* Unicode object */
) Py_DEPRECATED(3.3); );
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
/* Read a character from the string. */ /* Read a character from the string. */
@ -381,11 +381,11 @@ PyAPI_FUNC(PyObject*) PyUnicode_Decode(
Use PyCodec_Decode() to decode with rot13 and non-standard codecs Use PyCodec_Decode() to decode with rot13 and non-standard codecs
that decode from str. */ that decode from str. */
PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedObject( Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedObject(
PyObject *unicode, /* Unicode object */ PyObject *unicode, /* Unicode object */
const char *encoding, /* encoding */ const char *encoding, /* encoding */
const char *errors /* error handling */ const char *errors /* error handling */
) Py_DEPRECATED(3.6); );
/* Decode a Unicode object unicode and return the result as Unicode /* Decode a Unicode object unicode and return the result as Unicode
object. object.
@ -394,11 +394,11 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedObject(
Use PyCodec_Decode() to decode with rot13 and non-standard codecs Use PyCodec_Decode() to decode with rot13 and non-standard codecs
that decode from str to str. */ that decode from str to str. */
PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedUnicode( Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedUnicode(
PyObject *unicode, /* Unicode object */ PyObject *unicode, /* Unicode object */
const char *encoding, /* encoding */ const char *encoding, /* encoding */
const char *errors /* error handling */ const char *errors /* error handling */
) Py_DEPRECATED(3.6); );
/* Encodes a Unicode object and returns the result as Python /* Encodes a Unicode object and returns the result as Python
object. object.
@ -408,11 +408,11 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedUnicode(
Use PyCodec_Encode() for encoding with rot13 and non-standard codecs Use PyCodec_Encode() for encoding with rot13 and non-standard codecs
that encode form str to non-bytes. */ that encode form str to non-bytes. */
PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedObject( Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedObject(
PyObject *unicode, /* Unicode object */ PyObject *unicode, /* Unicode object */
const char *encoding, /* encoding */ const char *encoding, /* encoding */
const char *errors /* error handling */ const char *errors /* error handling */
) Py_DEPRECATED(3.6); );
/* Encodes a Unicode object and returns the result as Python string /* Encodes a Unicode object and returns the result as Python string
object. */ object. */
@ -430,11 +430,11 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedString(
Use PyCodec_Encode() to encode with rot13 and non-standard codecs Use PyCodec_Encode() to encode with rot13 and non-standard codecs
that encode from str to str. */ that encode from str to str. */
PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedUnicode( Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedUnicode(
PyObject *unicode, /* Unicode object */ PyObject *unicode, /* Unicode object */
const char *encoding, /* encoding */ const char *encoding, /* encoding */
const char *errors /* error handling */ const char *errors /* error handling */
) Py_DEPRECATED(3.6); );
/* Build an encoding map. */ /* Build an encoding map. */

View File

@ -0,0 +1 @@
The :c:macro:`Py_DEPRECATED()` macro has been implemented for MSVC.