summaryrefslogtreecommitdiffstats
path: root/Include/cpython
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2019-05-28 15:16:33 (GMT)
committerVictor Stinner <vstinner@redhat.com>2019-05-28 15:16:33 (GMT)
commit3c8724fc60163f4f3c3b0d531c84cc7b36783f82 (patch)
treebb195253b921a259f0a6e02ffc80f4eb6ad16738 /Include/cpython
parent17a5588740b3d126d546ad1a13bdac4e028e6d50 (diff)
downloadcpython-3c8724fc60163f4f3c3b0d531c84cc7b36783f82.zip
cpython-3c8724fc60163f4f3c3b0d531c84cc7b36783f82.tar.gz
cpython-3c8724fc60163f4f3c3b0d531c84cc7b36783f82.tar.bz2
bpo-33407: Implement Py_DEPRECATED() on MSVC (GH-8980)
Diffstat (limited to 'Include/cpython')
-rw-r--r--Include/cpython/pyerrors.h18
-rw-r--r--Include/cpython/unicodeobject.h127
2 files changed, 74 insertions, 71 deletions
diff --git a/Include/cpython/pyerrors.h b/Include/cpython/pyerrors.h
index 6b0cced..e3098b3 100644
--- a/Include/cpython/pyerrors.h
+++ b/Include/cpython/pyerrors.h
@@ -88,8 +88,9 @@ PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);
/* Convenience functions */
#ifdef MS_WINDOWS
+Py_DEPRECATED(3.3)
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
- PyObject *, const Py_UNICODE *) Py_DEPRECATED(3.3);
+ PyObject *, const Py_UNICODE *);
#endif /* MS_WINDOWS */
/* Like PyErr_Format(), but saves current exception as __context__ and
@@ -103,11 +104,12 @@ PyAPI_FUNC(PyObject *) _PyErr_FormatFromCause(
#ifdef MS_WINDOWS
/* XXX redeclare to use WSTRING */
+Py_DEPRECATED(3.3)
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(
- PyObject *,int, const Py_UNICODE *) Py_DEPRECATED(3.3);
+ PyObject *,int, const Py_UNICODE *);
#endif
/* In exceptions.c */
@@ -147,23 +149,23 @@ PyAPI_FUNC(PyObject *) PyErr_ProgramTextObject(
int lineno);
/* 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 Py_UNICODE *object,
Py_ssize_t length,
Py_ssize_t start,
Py_ssize_t end,
const char *reason /* UTF-8 encoded string */
- ) Py_DEPRECATED(3.3);
+ );
/* Create a UnicodeTranslateError object */
-PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
+Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
const Py_UNICODE *object,
Py_ssize_t length,
Py_ssize_t start,
Py_ssize_t end,
const char *reason /* UTF-8 encoded string */
- ) Py_DEPRECATED(3.3);
+ );
PyAPI_FUNC(PyObject *) _PyUnicodeTranslateError_Create(
PyObject *object,
Py_ssize_t start,
diff --git a/Include/cpython/unicodeobject.h b/Include/cpython/unicodeobject.h
index 806c3aa..c11503d 100644
--- a/Include/cpython/unicodeobject.h
+++ b/Include/cpython/unicodeobject.h
@@ -11,7 +11,7 @@ extern "C" {
With PEP 393, Py_UNICODE is deprecated and replaced with a
typedef to 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 ---------------------------------------- */
@@ -257,6 +257,7 @@ typedef struct {
If the Py_UNICODE representation is not available, it will be computed
on request. Use PyUnicode_GET_LENGTH() for the length in code points. */
+/* Py_DEPRECATED(3.3) */
#define PyUnicode_GET_SIZE(op) \
(assert(PyUnicode_Check(op)), \
(((PyASCIIObject *)(op))->wstr) ? \
@@ -264,26 +265,25 @@ typedef struct {
((void)PyUnicode_AsUnicode(_PyObject_CAST(op)),\
assert(((PyASCIIObject *)(op))->wstr), \
PyUnicode_WSTR_LENGTH(op)))
- /* Py_DEPRECATED(3.3) */
+/* Py_DEPRECATED(3.3) */
#define PyUnicode_GET_DATA_SIZE(op) \
(PyUnicode_GET_SIZE(op) * Py_UNICODE_SIZE)
- /* Py_DEPRECATED(3.3) */
/* Alias for PyUnicode_AsUnicode(). This will create a wchar_t/Py_UNICODE
representation on demand. Using this macro is very inefficient now,
try to port your code to use the new PyUnicode_*BYTE_DATA() macros or
use PyUnicode_WRITE() and PyUnicode_READ(). */
+/* Py_DEPRECATED(3.3) */
#define PyUnicode_AS_UNICODE(op) \
(assert(PyUnicode_Check(op)), \
(((PyASCIIObject *)(op))->wstr) ? (((PyASCIIObject *)(op))->wstr) : \
PyUnicode_AsUnicode(_PyObject_CAST(op)))
- /* Py_DEPRECATED(3.3) */
+/* Py_DEPRECATED(3.3) */
#define PyUnicode_AS_DATA(op) \
((const char *)(PyUnicode_AS_UNICODE(op)))
- /* Py_DEPRECATED(3.3) */
/* --- Flexible String Representation Helper Macros (PEP 393) -------------- */
@@ -543,10 +543,10 @@ PyAPI_FUNC(void) _PyUnicode_FastFill(
only allowed if u was set to NULL.
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 */
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.
Scan the string to find the maximum character. */
@@ -572,9 +572,9 @@ PyAPI_FUNC(Py_UCS4) _PyUnicode_FindMaxChar (
Py_UNICODE buffer.
If the wchar_t/Py_UNICODE representation is not yet available, this
function will calculate it. */
-PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
+/* Py_DEPRECATED(3.3) */ PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
PyObject *unicode /* Unicode object */
- ) /* Py_DEPRECATED(3.3) */;
+ );
/* Similar to PyUnicode_AsUnicode(), but raises a ValueError if the string
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
function will calculate it. */
-PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicodeAndSize(
+/* Py_DEPRECATED(3.3) */ PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicodeAndSize(
PyObject *unicode, /* Unicode object */
Py_ssize_t *size /* location where to save the length */
- ) /* Py_DEPRECATED(3.3) */;
+ );
/* 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 ----------------------------------------------- */
@@ -784,22 +784,22 @@ PyAPI_FUNC(const char *) PyUnicode_AsUTF8(PyObject *unicode);
/* Encodes a Py_UNICODE buffer of the given size and returns a
Python string object. */
-PyAPI_FUNC(PyObject*) PyUnicode_Encode(
+Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_Encode(
const Py_UNICODE *s, /* Unicode char buffer */
Py_ssize_t size, /* number of Py_UNICODE chars to encode */
const char *encoding, /* encoding */
const char *errors /* error handling */
- ) Py_DEPRECATED(3.3);
+ );
/* --- UTF-7 Codecs ------------------------------------------------------- */
-PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7(
+Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */
int base64SetO, /* Encode RFC2152 Set O characters in base64 */
int base64WhiteSpace, /* Encode whitespace (sp, ht, nl, cr) in base64 */
const char *errors /* error handling */
- ) Py_DEPRECATED(3.3);
+ );
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF7(
PyObject *unicode, /* Unicode object */
@@ -814,20 +814,20 @@ PyAPI_FUNC(PyObject*) _PyUnicode_AsUTF8String(
PyObject *unicode,
const char *errors);
-PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8(
+Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */
const char *errors /* error handling */
- ) Py_DEPRECATED(3.3);
+ );
/* --- UTF-32 Codecs ------------------------------------------------------ */
-PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF32(
+Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF32(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */
const char *errors, /* error handling */
int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
- ) Py_DEPRECATED(3.3);
+ );
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF32(
PyObject *object, /* Unicode object */
@@ -856,12 +856,12 @@ PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF32(
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 */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */
const char *errors, /* error handling */
int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
- ) Py_DEPRECATED(3.3);
+ );
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF16(
PyObject* unicode, /* Unicode object */
@@ -882,17 +882,17 @@ PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscape(
string. */
);
-PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape(
+Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length /* Number of Py_UNICODE chars to encode */
- ) Py_DEPRECATED(3.3);
+ );
/* --- 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 */
Py_ssize_t length /* Number of Py_UNICODE chars to encode */
- ) Py_DEPRECATED(3.3);
+ );
/* --- Latin-1 Codecs ----------------------------------------------------- */
@@ -900,11 +900,11 @@ PyAPI_FUNC(PyObject*) _PyUnicode_AsLatin1String(
PyObject* unicode,
const char* errors);
-PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1(
+Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
const char *errors /* error handling */
- ) Py_DEPRECATED(3.3);
+ );
/* --- ASCII Codecs ------------------------------------------------------- */
@@ -912,20 +912,20 @@ PyAPI_FUNC(PyObject*) _PyUnicode_AsASCIIString(
PyObject* unicode,
const char* errors);
-PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII(
+Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
const char *errors /* error handling */
- ) Py_DEPRECATED(3.3);
+ );
/* --- Character Map Codecs ----------------------------------------------- */
-PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap(
+Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap(
const Py_UNICODE *data, /* Unicode char buffer */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
PyObject *mapping, /* encoding mapping */
const char *errors /* error handling */
- ) Py_DEPRECATED(3.3);
+ );
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeCharmap(
PyObject *unicode, /* Unicode object */
@@ -945,21 +945,21 @@ PyAPI_FUNC(PyObject*) _PyUnicode_EncodeCharmap(
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 */
Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
PyObject *table, /* Translate table */
const char *errors /* error handling */
- ) Py_DEPRECATED(3.3);
+ );
/* --- MBCS codecs for 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 */
Py_ssize_t length, /* number of Py_UNICODE chars to encode */
const char *errors /* error handling */
- ) Py_DEPRECATED(3.3);
+ );
#endif
/* --- 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_ssize_t length, /* Number of Py_UNICODE chars to encode */
char *output, /* Output buffer; must have size >= length */
const char *errors /* error handling */
- ) /* Py_DEPRECATED(3.3) */;
+ );
/* Transforms code points that have decimal digit property to the
corresponding ASCII digit code points.
@@ -999,10 +999,11 @@ PyAPI_FUNC(int) PyUnicode_EncodeDecimal(
Returns a new Unicode string on success, NULL on failure.
*/
+/* Py_DEPRECATED(3.3) */
PyAPI_FUNC(PyObject*) PyUnicode_TransformDecimalToASCII(
Py_UNICODE *s, /* Unicode buffer */
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
for using in int, float and complex parsers.
@@ -1101,17 +1102,17 @@ PyAPI_FUNC(int) _PyUnicode_IsLinebreak(
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_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_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_DEPRECATED(3.3);
+ );
PyAPI_FUNC(int) _PyUnicode_ToLowerFull(
Py_UCS4 ch, /* Unicode character */
@@ -1173,42 +1174,42 @@ PyAPI_FUNC(int) _PyUnicode_IsAlpha(
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
- ) 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,
- const Py_UNICODE *s2) Py_DEPRECATED(3.3);
+ const Py_UNICODE *s2);
-PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strcat(
- Py_UNICODE *s1, const Py_UNICODE *s2) Py_DEPRECATED(3.3);
+Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strcat(
+ 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,
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 *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 *s2,
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,
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,
Py_UNICODE c
- ) Py_DEPRECATED(3.3);
+ );
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
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
- ) Py_DEPRECATED(3.3);
+ );
/* Return an interned Unicode object for an Identifier; may fail if there is no memory.*/
PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*);