[Python-checkins] bpo-19569: Add a macro to suppress deprecation warnings (GH-9004)
Zackery Spytz
webhook-mailer at python.org
Mon Jun 15 20:56:36 EDT 2020
https://github.com/python/cpython/commit/de4304dad8e035dbbb57d653e685312eead816df
commit: de4304dad8e035dbbb57d653e685312eead816df
branch: master
author: Zackery Spytz <zspytz at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020年06月16日T09:56:27+09:00
summary:
bpo-19569: Add a macro to suppress deprecation warnings (GH-9004)
Co-authored-by: Arfrever Frehtes Taifersar Arahesis <arfrever.fta at gmail.com>
files:
A Misc/NEWS.d/next/Core and Builtins/2018-08-29-15-57-07.bpo-19569.RGu2Kb.rst
M Include/pyport.h
diff --git a/Include/pyport.h b/Include/pyport.h
index 3c71f30bce16f..7137006870bf0 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -515,6 +515,26 @@ extern "C" {
#define Py_DEPRECATED(VERSION_UNUSED)
#endif
+#if defined(__clang__)
+#define _Py_COMP_DIAG_PUSH _Pragma("clang diagnostic push")
+#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \
+ _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
+#define _Py_COMP_DIAG_POP _Pragma("clang diagnostic pop")
+#elif defined(__GNUC__) \
+ && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
+#define _Py_COMP_DIAG_PUSH _Pragma("GCC diagnostic push")
+#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \
+ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+#define _Py_COMP_DIAG_POP _Pragma("GCC diagnostic pop")
+#elif defined(_MSC_VER)
+#define _Py_COMP_DIAG_PUSH __pragma(warning(push))
+#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS __pragma(warning(disable: 4996))
+#define _Py_COMP_DIAG_POP __pragma(warning(pop))
+#else
+#define _Py_COMP_DIAG_PUSH
+#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS
+#define _Py_COMP_DIAG_POP
+#endif
/* _Py_HOT_FUNCTION
* The hot attribute on a function is used to inform the compiler that the
diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-08-29-15-57-07.bpo-19569.RGu2Kb.rst b/Misc/NEWS.d/next/Core and Builtins/2018-08-29-15-57-07.bpo-19569.RGu2Kb.rst
new file mode 100644
index 0000000000000..1b76bd8e247fc
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2018-08-29-15-57-07.bpo-19569.RGu2Kb.rst
@@ -0,0 +1,2 @@
+Add the private macros ``_Py_COMP_DIAG_PUSH``,
+``_Py_COMP_DIAG_IGNORE_DEPR_DECLS``, and ``_Py_COMP_DIAG_POP``.
More information about the Python-checkins
mailing list