Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3c8724fc
Commit
3c8724fc
authored
May 28, 2019
by
Zackery Spytz
Committed by
Victor Stinner
May 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-33407: Implement Py_DEPRECATED() on MSVC (GH-8980)
parent
17a55887
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
136 additions
and
104 deletions
+136
-104
Doc/c-api/intro.rst
Doc/c-api/intro.rst
+12
-0
Doc/whatsnew/3.8.rst
Doc/whatsnew/3.8.rst
+9
-0
Include/abstract.h
Include/abstract.h
+7
-8
Include/ceval.h
Include/ceval.h
+2
-2
Include/cpython/pyerrors.h
Include/cpython/pyerrors.h
+10
-8
Include/cpython/unicodeobject.h
Include/cpython/unicodeobject.h
+64
-63
Include/intrcheck.h
Include/intrcheck.h
+1
-1
Include/longobject.h
Include/longobject.h
+2
-1
Include/moduleobject.h
Include/moduleobject.h
+1
-1
Include/pyport.h
Include/pyport.h
+7
-3
Include/pythread.h
Include/pythread.h
+7
-6
Include/sliceobject.h
Include/sliceobject.h
+3
-1
Include/unicodeobject.h
Include/unicodeobject.h
+10
-10
Misc/NEWS.d/next/Windows/2018-08-28-17-23-49.bpo-33407.ARG0W_.rst
...S.d/next/Windows/2018-08-28-17-23-49.bpo-33407.ARG0W_.rst
+1
-0
No files found.
Doc/c-api/intro.rst
View file @
3c8724fc
...
...
@@ -160,6 +160,18 @@ complete listing.
.. 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:
...
...
Doc/whatsnew/3.8.rst
View file @
3c8724fc
...
...
@@ -1240,6 +1240,15 @@ Changes in the C API
(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
------------------------
...
...
Include/abstract.h
View file @
3c8724fc
...
...
@@ -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
occurs. Otherwise, -1 is returned and an exception set. */
Py_DEPRECATED
(
3
.
0
)
PyAPI_FUNC
(
int
)
PyObject_AsCharBuffer
(
PyObject
*
obj
,
const
char
**
buffer
,
Py_ssize_t
*
buffer_len
)
Py_DEPRECATED
(
3
.
0
);
Py_ssize_t
*
buffer_len
);
/* Checks whether an arbitrary object supports the (character, single segment)
buffer interface.
Returns 1 on success, 0 on failure. */
PyAPI_FUNC
(
int
)
PyObject_CheckReadBuffer
(
PyObject
*
obj
)
Py_DEPRECATED
(
3
.
0
);
Py_DEPRECATED
(
3
.
0
)
PyAPI_FUNC
(
int
)
PyObject_CheckReadBuffer
(
PyObject
*
obj
);
/* Same as PyObject_AsCharBuffer() except that this API expects (readable,
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
error occurs. Otherwise, -1 is returned and an exception set. */
Py_DEPRECATED
(
3
.
0
)
PyAPI_FUNC
(
int
)
PyObject_AsReadBuffer
(
PyObject
*
obj
,
const
void
**
buffer
,
Py_ssize_t
*
buffer_len
)
Py_DEPRECATED
(
3
.
0
);
Py_ssize_t
*
buffer_len
);
/* Takes an arbitrary object which must support the (writable, single segment)
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
occurs. Otherwise, -1 is returned and an exception set. */
Py_DEPRECATED
(
3
.
0
)
PyAPI_FUNC
(
int
)
PyObject_AsWriteBuffer
(
PyObject
*
obj
,
void
**
buffer
,
Py_ssize_t
*
buffer_len
)
Py_DEPRECATED
(
3
.
0
);
Py_ssize_t
*
buffer_len
);
/* === New Buffer API ============================================ */
...
...
Include/ceval.h
View file @
3c8724fc
...
...
@@ -189,8 +189,8 @@ PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);
PyAPI_FUNC
(
int
)
PyEval_ThreadsInitialized
(
void
);
PyAPI_FUNC
(
void
)
PyEval_InitThreads
(
void
);
Py
API_FUNC
(
void
)
PyEval_AcquireLock
(
void
)
Py_DEPRECATED
(
3
.
2
);
PyAPI_FUNC
(
void
)
PyEval_ReleaseLock
(
void
)
/* Py_DEPRECATED(3.2) */
;
Py
_DEPRECATED
(
3
.
2
)
PyAPI_FUNC
(
void
)
PyEval_AcquireLock
(
void
);
/* Py_DEPRECATED(3.2) */
PyAPI_FUNC
(
void
)
PyEval_ReleaseLock
(
void
)
;
PyAPI_FUNC
(
void
)
PyEval_AcquireThread
(
PyThreadState
*
tstate
);
PyAPI_FUNC
(
void
)
PyEval_ReleaseThread
(
PyThreadState
*
tstate
);
...
...
Include/cpython/pyerrors.h
View file @
3c8724fc
...
...
@@ -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
)
Py
API_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
)
Py
API_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
,
...
...
Include/cpython/unicodeobject.h
View file @
3c8724fc
This diff is collapsed.
Click to expand it.
Include/intrcheck.h
View file @
3c8724fc
...
...
@@ -15,7 +15,7 @@ PyAPI_FUNC(void) PyOS_AfterFork_Child(void);
#endif
#endif
/* Deprecated, please use PyOS_AfterFork_Child() instead */
Py
API_FUNC
(
void
)
PyOS_AfterFork
(
void
)
Py_DEPRECATED
(
3
.
7
);
Py
_DEPRECATED
(
3
.
7
)
PyAPI_FUNC
(
void
)
PyOS_AfterFork
(
void
);
#ifndef Py_LIMITED_API
PyAPI_FUNC
(
int
)
_PyOS_IsMainThread
(
void
);
...
...
Include/longobject.h
View file @
3c8724fc
...
...
@@ -102,7 +102,8 @@ PyAPI_FUNC(long long) PyLong_AsLongLongAndOverflow(PyObject *, int *);
PyAPI_FUNC
(
PyObject
*
)
PyLong_FromString
(
const
char
*
,
char
**
,
int
);
#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_FromBytes
(
const
char
*
,
Py_ssize_t
,
int
);
#endif
...
...
Include/moduleobject.h
View file @
3c8724fc
...
...
@@ -25,7 +25,7 @@ PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);
PyAPI_FUNC
(
PyObject
*
)
PyModule_GetNameObject
(
PyObject
*
);
#endif
PyAPI_FUNC
(
const
char
*
)
PyModule_GetName
(
PyObject
*
);
Py
API_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
*
);
#ifndef Py_LIMITED_API
PyAPI_FUNC
(
void
)
_PyModule_Clear
(
PyObject
*
);
...
...
Include/pyport.h
View file @
3c8724fc
...
...
@@ -504,14 +504,18 @@ extern "C" {
/* Py_DEPRECATED(version)
* Declare a variable, type, or function deprecated.
* The macro must be placed before the declaration.
* Usage:
*
extern int old_var Py_DEPRECATED(2.3)
;
*
typedef int T1 Py_DEPRECATED(2.4)
;
*
extern int x() Py_DEPRECATED(2.5
);
*
Py_DEPRECATED(3.3) extern int old_var
;
*
Py_DEPRECATED(3.4) typedef int T1
;
*
Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void
);
*/
#if defined(__GNUC__) \
&& ((__GNUC__ >= 4) || (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
#elif defined(_MSC_VER)
#define Py_DEPRECATED(VERSION) __declspec(deprecated( \
"deprecated in " #VERSION))
#else
#define Py_DEPRECATED(VERSION_UNUSED)
#endif
...
...
Include/pythread.h
View file @
3c8724fc
...
...
@@ -97,14 +97,15 @@ PyAPI_FUNC(PyObject*) PyThread_GetInfo(void);
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).
*/
PyAPI_FUNC
(
int
)
PyThread_create_key
(
void
)
Py_DEPRECATED
(
3
.
7
);
PyAPI_FUNC
(
void
)
PyThread_delete_key
(
int
key
)
Py_DEPRECATED
(
3
.
7
);
PyAPI_FUNC
(
int
)
PyThread_set_key_value
(
int
key
,
void
*
value
)
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
)
Py_DEPRECATED
(
3
.
7
);
Py_DEPRECATED
(
3
.
7
)
PyAPI_FUNC
(
int
)
PyThread_create_key
(
void
);
Py_DEPRECATED
(
3
.
7
)
PyAPI_FUNC
(
void
)
PyThread_delete_key
(
int
key
);
Py_DEPRECATED
(
3
.
7
)
PyAPI_FUNC
(
int
)
PyThread_set_key_value
(
int
key
,
void
*
value
);
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 */
Py
API_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
...
...
Include/sliceobject.h
View file @
3c8724fc
...
...
@@ -40,9 +40,11 @@ PyAPI_FUNC(int) _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
#endif
PyAPI_FUNC
(
int
)
PySlice_GetIndices
(
PyObject
*
r
,
Py_ssize_t
length
,
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
,
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
#define PySlice_GetIndicesEx(slice, length, start, stop, step, slicelen) ( \
...
...
Include/unicodeobject.h
View file @
3c8724fc
...
...
@@ -174,9 +174,9 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_GetLength(
/* Get the number of Py_UNICODE units in the
string representation. */
PyAPI_FUNC
(
Py_ssize_t
)
PyUnicode_GetSize
(
Py
_DEPRECATED
(
3
.
3
)
Py
API_FUNC
(
Py_ssize_t
)
PyUnicode_GetSize
(
PyObject
*
unicode
/* Unicode object */
)
Py_DEPRECATED
(
3
.
3
)
;
);
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
/* 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
that decode from str. */
PyAPI_FUNC
(
PyObject
*
)
PyUnicode_AsDecodedObject
(
Py
_DEPRECATED
(
3
.
6
)
Py
API_FUNC
(
PyObject
*
)
PyUnicode_AsDecodedObject
(
PyObject
*
unicode
,
/* Unicode object */
const
char
*
encoding
,
/* encoding */
const
char
*
errors
/* error handling */
)
Py_DEPRECATED
(
3
.
6
)
;
);
/* Decode a Unicode object unicode and return the result as Unicode
object.
...
...
@@ -394,11 +394,11 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedObject(
Use PyCodec_Decode() to decode with rot13 and non-standard codecs
that decode from str to str. */
PyAPI_FUNC
(
PyObject
*
)
PyUnicode_AsDecodedUnicode
(
Py
_DEPRECATED
(
3
.
6
)
Py
API_FUNC
(
PyObject
*
)
PyUnicode_AsDecodedUnicode
(
PyObject
*
unicode
,
/* Unicode object */
const
char
*
encoding
,
/* encoding */
const
char
*
errors
/* error handling */
)
Py_DEPRECATED
(
3
.
6
)
;
);
/* Encodes a Unicode object and returns the result as Python
object.
...
...
@@ -408,11 +408,11 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedUnicode(
Use PyCodec_Encode() for encoding with rot13 and non-standard codecs
that encode form str to non-bytes. */
PyAPI_FUNC
(
PyObject
*
)
PyUnicode_AsEncodedObject
(
Py
_DEPRECATED
(
3
.
6
)
Py
API_FUNC
(
PyObject
*
)
PyUnicode_AsEncodedObject
(
PyObject
*
unicode
,
/* Unicode object */
const
char
*
encoding
,
/* encoding */
const
char
*
errors
/* error handling */
)
Py_DEPRECATED
(
3
.
6
)
;
);
/* Encodes a Unicode object and returns the result as Python string
object. */
...
...
@@ -430,11 +430,11 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedString(
Use PyCodec_Encode() to encode with rot13 and non-standard codecs
that encode from str to str. */
PyAPI_FUNC
(
PyObject
*
)
PyUnicode_AsEncodedUnicode
(
Py
_DEPRECATED
(
3
.
6
)
Py
API_FUNC
(
PyObject
*
)
PyUnicode_AsEncodedUnicode
(
PyObject
*
unicode
,
/* Unicode object */
const
char
*
encoding
,
/* encoding */
const
char
*
errors
/* error handling */
)
Py_DEPRECATED
(
3
.
6
)
;
);
/* Build an encoding map. */
...
...
Misc/NEWS.d/next/Windows/2018-08-28-17-23-49.bpo-33407.ARG0W_.rst
0 → 100644
View file @
3c8724fc
The :c:macro:`Py_DEPRECATED()` macro has been implemented for MSVC.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment