From f81a68e1a9c13c6ec282460f89b0e818ce137560 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sun, 22 Dec 2024 11:24:50 +0800 Subject: [PATCH] More affordances for older macOS SDKs. --- Python/pylifecycle.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index f6cc26f8fb7474..4c174281d6f66d 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -46,10 +46,23 @@ #if defined(__APPLE__) # include +# include # include // The os_log unified logging APIs were introduced in macOS 10.12, iOS 10.0, // tvOS 10.0, and watchOS 3.0; -# if TARGET_OS_IPHONE || (TARGET_OS_OSX && defined(MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12) +# if defined(TARGET_OS_IPHONE) && TARGET_IOS_IPHONE +# define HAS_APPLE_SYSTEM_LOG 1 +# elif defined(TARGET_OS_OSX) && TARGET_OS_OSX +# if defined(MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 +# define HAS_APPLE_SYSTEM_LOG 1 +# else +# define HAS_APPLE_SYSTEM_LOG 0 +# endif +# else +# define HAS_APPLE_SYSTEM_LOG 0 +# endif + +# if HAS_APPLE_SYSTEM_LOG # include # endif #endif @@ -2964,7 +2977,7 @@ apple_log_write_impl(PyObject *self, PyObject *args) // Call the underlying Apple logging API. The os_log unified logging APIs // were introduced in macOS 10.12, iOS 10.0, tvOS 10.0, and watchOS 3.0; // this call is a no-op on older versions. - #if TARGET_OS_IPHONE || (TARGET_OS_OSX && defined(MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12) + #if HAS_APPLE_SYSTEM_LOG // Pass the user-provided text through explicit %s formatting // to avoid % literals being interpreted as a formatting directive. os_log_with_type(OS_LOG_DEFAULT, logtype, "%s", text);