This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Implement Py_DEPRECATED() macro for Visual Studio
Type: Stage: resolved
Components: Windows Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ZackerySpytz, paul.moore, pitrou, steve.dower, tim.golden, vstinner, zach.ware
Priority: normal Keywords: patch

Created on 2018-05-02 09:29 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 8980 merged ZackerySpytz, 2018-08-28 22:09
Messages (5)
msg316059 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-05-02 09:29
According to the following links, it would be possible to implement the Pc_DEPRECATED() macro for Visual Studio:

https://mail.python.org/pipermail/python-dev/2018-May/153299.html
https://stackoverflow.com/questions/295120/c-mark-as-deprecated/295229#295229

"""
#ifdef __GNUC__
#define DEPRECATED(func) func __attribute__ ((deprecated))
#elif defined(_MSC_VER)
#define DEPRECATED(func) __declspec(deprecated) func
#else
#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
#define DEPRECATED(func) func
#endif
"""

Moreover, is Py_DEPRECATED() defined on clang which also supports the deprecated function attribute?
https://clang.llvm.org/docs/AttributeReference.html#deprecated-gnu-deprecated

Current Include/pyport.h code:

#if defined(__GNUC__) \
    && ((__GNUC__ >= 4) || (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
#else
#define Py_DEPRECATED(VERSION_UNUSED)
#endif
msg316060 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-05-02 09:31
Oh, bpo-19569 is still open, for Visual Studio see:
https://bugs.python.org/issue19569#msg227727
msg316061 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2018-05-02 09:35
In Arrow we use the following:

#if __cplusplus <= 201103L
# ifdef __GNUC__
#  define ARROW_DEPRECATED(...) __attribute__((deprecated(__VA_ARGS__)))
# elif defined(_MSC_VER)
#  define ARROW_DEPRECATED(...) __declspec(deprecated(__VA_ARGS__))
# else
#  define ARROW_DEPRECATED(...)
# endif
#else
#  define ARROW_DEPRECATED(...) [[deprecated(__VA_ARGS__)]]
#endif
msg343789 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-05-28 15:16
New changeset 3c8724fc60163f4f3c3b0d531c84cc7b36783f82 by Victor Stinner (Zackery Spytz) in branch 'master':
bpo-33407: Implement Py_DEPRECATED() on MSVC (GH-8980)
https://github.com/python/cpython/commit/3c8724fc60163f4f3c3b0d531c84cc7b36783f82
msg343790 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-05-28 15:19
Thanks Zackery Spytz for the fix!
History
Date User Action Args
2022-04-11 14:59:00adminsetgithub: 77588
2019-05-28 15:19:44vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg343790

stage: patch review -> resolved
2019-05-28 15:16:56vstinnersetmessages: + msg343789
2018-08-28 22:26:43ZackerySpytzsetnosy: + ZackerySpytz
2018-08-28 22:09:42ZackerySpytzsetkeywords: + patch
stage: patch review
pull_requests: + pull_request8454
2018-05-02 09:35:26pitrousetmessages: + msg316061
2018-05-02 09:31:41vstinnersetmessages: + msg316060
2018-05-02 09:29:49vstinnercreate