]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-130940: Modify default behavior of `PyConfig.use_system_logger` to enable on iOS...
authorRussell Keith-Magee <russell@keith-magee.com>
Thu, 13 Mar 2025 06:28:49 +0000 (14:28 +0800)
committerGitHub <noreply@github.com>
Thu, 13 Mar 2025 06:28:49 +0000 (14:28 +0800)
Modify default behavior of use_system_log to enable on iOS.

Doc/c-api/init_config.rst
Doc/using/ios.rst
Misc/NEWS.d/next/Library/2025-03-13-07-06-22.gh-issue-130940.i5cUI5.rst [new file with mode: 0644]
Python/initconfig.c

index b791d3cdc5d95ca4204ca1df2828b63b74d2d342..be9f5e7649ba7851b140efc5a31c74870a3642df 100644 (file)
@@ -505,6 +505,10 @@ Configuration Options
      - :c:member:`use_hash_seed <PyConfig.use_hash_seed>`
      - ``bool``
      - Read-only
+   * - ``"use_system_logger"``
+     - :c:member:`use_system_logger <PyConfig.use_system_logger>`
+     - ``bool``
+     - Read-only
    * - ``"user_site_directory"``
      - :c:member:`user_site_directory <PyConfig.user_site_directory>`
      - ``bool``
@@ -1927,9 +1931,10 @@ PyConfig
 
       Only available on macOS 10.12 and later, and on iOS.
 
-      Default: ``0`` (don't use system log).
+      Default: ``0`` (don't use the system log) on macOS; ``1`` on iOS (use the
+      system log).
 
-      .. versionadded:: 3.13.2
+      .. versionadded:: 3.14
 
    .. c:member:: int user_site_directory
 
index aa43f75ec35a6ca9f4730490964e432ddd74fb7e..7d5c6331bef5ce0bbd62b48f635de6f3431abe31 100644 (file)
@@ -297,7 +297,7 @@ To add Python to an iOS Xcode project:
    * Writing bytecode (:c:member:`PyConfig.write_bytecode`) is *disabled*;
    * Signal handlers (:c:member:`PyConfig.install_signal_handlers`) are *enabled*;
    * System logging (:c:member:`PyConfig.use_system_logger`) is *enabled*
-     (optional, but strongly recommended);
+     (optional, but strongly recommended; this is enabled by default);
    * ``PYTHONHOME`` for the interpreter is configured to point at the
      ``python`` subfolder of your app's bundle; and
    * The ``PYTHONPATH`` for the interpreter includes:
diff --git a/Misc/NEWS.d/next/Library/2025-03-13-07-06-22.gh-issue-130940.i5cUI5.rst b/Misc/NEWS.d/next/Library/2025-03-13-07-06-22.gh-issue-130940.i5cUI5.rst
new file mode 100644 (file)
index 0000000..643a961
--- /dev/null
@@ -0,0 +1,2 @@
+The behavior of ``PyConfig.use_system_logger`` was modified to be enabled by
+default on iOS. It remains disabled by default on macOS.
index d1e412295563cc6026521d627a5d1d778977db9d..1fe92a021312fae38a9df6ff995505a38c7b88c0 100644 (file)
 #  endif
 #endif
 
+#ifdef __APPLE__
+/* Enable system log by default on non-macOS Apple platforms */
+#  if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
+#define USE_SYSTEM_LOGGER_DEFAULT 1;
+#  else
+#define USE_SYSTEM_LOGGER_DEFAULT 0;
+#  endif
+#endif
+
 #include "config_common.h"
 
 /* --- PyConfig setters ------------------------------------------- */
@@ -1017,7 +1026,7 @@ _PyConfig_InitCompatConfig(PyConfig *config)
     config->code_debug_ranges = 1;
     config->cpu_count = -1;
 #ifdef __APPLE__
-    config->use_system_logger = 0;
+    config->use_system_logger = USE_SYSTEM_LOGGER_DEFAULT;
 #endif
 #ifdef Py_GIL_DISABLED
     config->enable_gil = _PyConfig_GIL_DEFAULT;
@@ -1049,7 +1058,7 @@ config_init_defaults(PyConfig *config)
     config->legacy_windows_stdio = 0;
 #endif
 #ifdef __APPLE__
-    config->use_system_logger = 0;
+    config->use_system_logger = USE_SYSTEM_LOGGER_DEFAULT;
 #endif
 }
 
@@ -1086,7 +1095,7 @@ PyConfig_InitIsolatedConfig(PyConfig *config)
     config->legacy_windows_stdio = 0;
 #endif
 #ifdef __APPLE__
-    config->use_system_logger = 0;
+    config->use_system_logger = USE_SYSTEM_LOGGER_DEFAULT;
 #endif
 }