https://github.com/python/cpython/commit/dd6d24e9d20407ea31a3bb653eab252ee0d41ffa
commit: dd6d24e9d20407ea31a3bb653eab252ee0d41ffa
branch: main
author: Russell Keith-Magee <russ...@keith-magee.com>
committer: freakboy3742 <russ...@keith-magee.com>
date: 2025-03-13T14:28:49+08:00
summary:

gh-130940: Modify default behavior of `PyConfig.use_system_logger` to enable on 
iOS (#131172)

Modify default behavior of use_system_log to enable on iOS.

files:
A Misc/NEWS.d/next/Library/2025-03-13-07-06-22.gh-issue-130940.i5cUI5.rst
M Doc/c-api/init_config.rst
M Doc/using/ios.rst
M Python/initconfig.c

diff --git a/Doc/c-api/init_config.rst b/Doc/c-api/init_config.rst
index b791d3cdc5d95c..be9f5e7649ba78 100644
--- a/Doc/c-api/init_config.rst
+++ b/Doc/c-api/init_config.rst
@@ -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
 
diff --git a/Doc/using/ios.rst b/Doc/using/ios.rst
index aa43f75ec35a6c..7d5c6331bef5ce 100644
--- a/Doc/using/ios.rst
+++ b/Doc/using/ios.rst
@@ -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
index 00000000000000..643a96173cd408
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-03-13-07-06-22.gh-issue-130940.i5cUI5.rst
@@ -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.
diff --git a/Python/initconfig.c b/Python/initconfig.c
index d1e412295563cc..1fe92a021312fa 100644
--- a/Python/initconfig.c
+++ b/Python/initconfig.c
@@ -25,6 +25,15 @@
 #  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
 }
 

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to