5050# include <mach-o/loader.h>
5151// The os_log unified logging APIs were introduced in macOS 10.12, iOS 10.0,
5252// tvOS 10.0, and watchOS 3.0;
53- # if defined(TARGET_OS_IPHONE ) && TARGET_IOS_IPHONE
53+ # if defined(TARGET_OS_IPHONE ) && TARGET_OS_IPHONE
5454# define HAS_APPLE_SYSTEM_LOG 1
5555# elif defined(TARGET_OS_OSX ) && TARGET_OS_OSX
5656# if defined(MAC_OS_X_VERSION_10_12 ) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
@@ -94,7 +94,7 @@ static PyStatus init_sys_streams(PyThreadState *tstate);
9494#ifdef __ANDROID__
9595static PyStatus init_android_streams (PyThreadState * tstate );
9696#endif
97- #if defined(__APPLE__ )
97+ #if defined(__APPLE__ ) && HAS_APPLE_SYSTEM_LOG
9898static PyStatus init_apple_streams (PyThreadState * tstate );
9999#endif
100100static void wait_for_thread_shutdown (PyThreadState * tstate );
@@ -1279,7 +1279,7 @@ init_interp_main(PyThreadState *tstate)
12791279 return status ;
12801280 }
12811281#endif
1282- #if defined(__APPLE__ )
1282+ #if defined(__APPLE__ ) && HAS_APPLE_SYSTEM_LOG
12831283 if (config -> use_system_logger ) {
12841284 status = init_apple_streams (tstate );
12851285 if (_PyStatus_EXCEPTION (status )) {
@@ -2963,7 +2963,7 @@ init_android_streams(PyThreadState *tstate)
29632963
29642964#endif // __ANDROID__
29652965
2966- #if defined(__APPLE__ )
2966+ #if defined(__APPLE__ ) && HAS_APPLE_SYSTEM_LOG
29672967
29682968static PyObject *
29692969apple_log_write_impl (PyObject * self , PyObject * args )
@@ -2974,14 +2974,9 @@ apple_log_write_impl(PyObject *self, PyObject *args)
29742974 return NULL ;
29752975 }
29762976
2977- // Call the underlying Apple logging API. The os_log unified logging APIs
2978- // were introduced in macOS 10.12, iOS 10.0, tvOS 10.0, and watchOS 3.0;
2979- // this call is a no-op on older versions.
2980- #if HAS_APPLE_SYSTEM_LOG
29812977 // Pass the user-provided text through explicit %s formatting
29822978 // to avoid % literals being interpreted as a formatting directive.
29832979 os_log_with_type (OS_LOG_DEFAULT , logtype , "%s" , text );
2984- #endif
29852980 Py_RETURN_NONE ;
29862981}
29872982
@@ -3016,7 +3011,6 @@ init_apple_streams(PyThreadState *tstate)
30163011 if (result == NULL ) {
30173012 goto error ;
30183013 }
3019-
30203014 goto done ;
30213015
30223016error :
@@ -3030,7 +3024,7 @@ init_apple_streams(PyThreadState *tstate)
30303024 return status ;
30313025}
30323026
3033- #endif // __APPLE__
3027+ #endif // __APPLE__ && HAS_APPLE_SYSTEM_LOG
30343028
30353029
30363030static void
0 commit comments