Skip to content

Commit 589f422

Browse files
authored
[3.13] gh-130940: Remove PyConfig.use_system_logger (#131129)
Removes ``PyConfig.use_system_logger``, resolving an ABI incompatibility introduced in 3.13.2. Changes the default behavior of iOS to *always* direct stdout/stderr to the system log.
1 parent 65b5829 commit 589f422

File tree

9 files changed

+19
-57
lines changed

9 files changed

+19
-57
lines changed

Doc/c-api/init_config.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,17 +1271,6 @@ PyConfig
12711271
12721272
Default: ``1`` in Python config and ``0`` in isolated config.
12731273
1274-
.. c:member:: int use_system_logger
1275-
1276-
If non-zero, ``stdout`` and ``stderr`` will be redirected to the system
1277-
log.
1278-
1279-
Only available on macOS 10.12 and later, and on iOS.
1280-
1281-
Default: ``0`` (don't use system log).
1282-
1283-
.. versionadded:: 3.13.2
1284-
12851274
.. c:member:: int user_site_directory
12861275
12871276
If non-zero, add the user site directory to :data:`sys.path`.

Doc/using/ios.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,6 @@ To add Python to an iOS Xcode project:
296296
* Buffered stdio (:c:member:`PyConfig.buffered_stdio`) is *disabled*;
297297
* Writing bytecode (:c:member:`PyConfig.write_bytecode`) is *disabled*;
298298
* Signal handlers (:c:member:`PyConfig.install_signal_handlers`) are *enabled*;
299-
* System logging (:c:member:`PyConfig.use_system_logger`) is *enabled*
300-
(optional, but strongly recommended);
301299
* ``PYTHONHOME`` for the interpreter is configured to point at the
302300
``python`` subfolder of your app's bundle; and
303301
* The ``PYTHONPATH`` for the interpreter includes:

Include/cpython/initconfig.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,6 @@ typedef struct PyConfig {
179179
int use_frozen_modules;
180180
int safe_path;
181181
int int_max_str_digits;
182-
#ifdef __APPLE__
183-
int use_system_logger;
184-
#endif
185182

186183
int cpu_count;
187184
#ifdef Py_GIL_DISABLED

Lib/test/test_apple.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import unittest
22
from _apple_support import SystemLog
3-
from test.support import is_apple
3+
from test.support import is_apple_mobile
44
from unittest.mock import Mock, call
55

6-
if not is_apple:
7-
raise unittest.SkipTest("Apple-specific")
6+
if not is_apple_mobile:
7+
raise unittest.SkipTest("iOS-specific")
88

99

1010
# Test redirection of stdout and stderr to the Apple system log.

Lib/test/test_embed.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
627627
CONFIG_COMPAT.update({
628628
'legacy_windows_stdio': 0,
629629
})
630-
if support.is_apple:
631-
CONFIG_COMPAT['use_system_logger'] = False
632630

633631
CONFIG_PYTHON = dict(CONFIG_COMPAT,
634632
_config_init=API_PYTHON,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The ``PyConfig.use_system_logger`` attribute, introduced in Python 3.13.2, has
2+
been removed. The introduction of this attribute inadvertently introduced an
3+
ABI breakage on macOS and iOS. The use of the system logger is now enabled
4+
by default on iOS, and disabled by default on macOS.

Python/initconfig.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@ static const PyConfigSpec PYCONFIG_SPEC[] = {
130130
#ifdef Py_DEBUG
131131
SPEC(run_presite, WSTR_OPT),
132132
#endif
133-
#ifdef __APPLE__
134-
SPEC(use_system_logger, BOOL),
135-
#endif
136133

137134
{NULL, 0, 0},
138135
};
@@ -751,9 +748,6 @@ config_check_consistency(const PyConfig *config)
751748
assert(config->cpu_count != 0);
752749
// config->use_frozen_modules is initialized later
753750
// by _PyConfig_InitImportConfig().
754-
#ifdef __APPLE__
755-
assert(config->use_system_logger >= 0);
756-
#endif
757751
#ifdef Py_STATS
758752
assert(config->_pystats >= 0);
759753
#endif
@@ -856,9 +850,6 @@ _PyConfig_InitCompatConfig(PyConfig *config)
856850
config->_is_python_build = 0;
857851
config->code_debug_ranges = 1;
858852
config->cpu_count = -1;
859-
#ifdef __APPLE__
860-
config->use_system_logger = 0;
861-
#endif
862853
#ifdef Py_GIL_DISABLED
863854
config->enable_gil = _PyConfig_GIL_DEFAULT;
864855
#endif
@@ -887,9 +878,6 @@ config_init_defaults(PyConfig *config)
887878
#ifdef MS_WINDOWS
888879
config->legacy_windows_stdio = 0;
889880
#endif
890-
#ifdef __APPLE__
891-
config->use_system_logger = 0;
892-
#endif
893881
}
894882

895883

@@ -925,9 +913,6 @@ PyConfig_InitIsolatedConfig(PyConfig *config)
925913
#ifdef MS_WINDOWS
926914
config->legacy_windows_stdio = 0;
927915
#endif
928-
#ifdef __APPLE__
929-
config->use_system_logger = 0;
930-
#endif
931916
}
932917

933918

Python/pylifecycle.c

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,15 @@
4747
# include <TargetConditionals.h>
4848
# include <mach-o/loader.h>
4949
// The os_log unified logging APIs were introduced in macOS 10.12, iOS 10.0,
50-
// tvOS 10.0, and watchOS 3.0;
50+
// tvOS 10.0, and watchOS 3.0; we enable the use of the system logger
51+
// automatically on non-macOS platforms.
5152
# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
52-
# define HAS_APPLE_SYSTEM_LOG 1
53-
# elif defined(TARGET_OS_OSX) && TARGET_OS_OSX
54-
# if defined(MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
55-
# define HAS_APPLE_SYSTEM_LOG 1
56-
# else
57-
# define HAS_APPLE_SYSTEM_LOG 0
58-
# endif
53+
# define USE_APPLE_SYSTEM_LOG 1
5954
# else
60-
# define HAS_APPLE_SYSTEM_LOG 0
55+
# define USE_APPLE_SYSTEM_LOG 0
6156
# endif
6257

63-
# if HAS_APPLE_SYSTEM_LOG
58+
# if USE_APPLE_SYSTEM_LOG
6459
# include <os/log.h>
6560
# endif
6661
#endif
@@ -92,7 +87,7 @@ static PyStatus init_sys_streams(PyThreadState *tstate);
9287
#ifdef __ANDROID__
9388
static PyStatus init_android_streams(PyThreadState *tstate);
9489
#endif
95-
#if defined(__APPLE__) && HAS_APPLE_SYSTEM_LOG
90+
#if defined(__APPLE__) && USE_APPLE_SYSTEM_LOG
9691
static PyStatus init_apple_streams(PyThreadState *tstate);
9792
#endif
9893
static void wait_for_thread_shutdown(PyThreadState *tstate);
@@ -1280,12 +1275,10 @@ init_interp_main(PyThreadState *tstate)
12801275
return status;
12811276
}
12821277
#endif
1283-
#if defined(__APPLE__) && HAS_APPLE_SYSTEM_LOG
1284-
if (config->use_system_logger) {
1285-
status = init_apple_streams(tstate);
1286-
if (_PyStatus_EXCEPTION(status)) {
1287-
return status;
1288-
}
1278+
#if defined(__APPLE__) && USE_APPLE_SYSTEM_LOG
1279+
status = init_apple_streams(tstate);
1280+
if (_PyStatus_EXCEPTION(status)) {
1281+
return status;
12891282
}
12901283
#endif
12911284

@@ -2971,7 +2964,7 @@ init_android_streams(PyThreadState *tstate)
29712964

29722965
#endif // __ANDROID__
29732966

2974-
#if defined(__APPLE__) && HAS_APPLE_SYSTEM_LOG
2967+
#if defined(__APPLE__) && USE_APPLE_SYSTEM_LOG
29752968

29762969
static PyObject *
29772970
apple_log_write_impl(PyObject *self, PyObject *args)
@@ -3032,7 +3025,7 @@ init_apple_streams(PyThreadState *tstate)
30323025
return status;
30333026
}
30343027

3035-
#endif // __APPLE__ && HAS_APPLE_SYSTEM_LOG
3028+
#endif // __APPLE__ && USE_APPLE_SYSTEM_LOG
30363029

30373030

30383031
static void

iOS/testbed/iOSTestbedTests/iOSTestbedTests.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ - (void)testPython {
5353
// Enforce UTF-8 encoding for stderr, stdout, file-system encoding and locale.
5454
// See https://docs.python.org/3/library/os.html#python-utf-8-mode.
5555
preconfig.utf8_mode = 1;
56-
// Use the system logger for stdout/err
57-
config.use_system_logger = 1;
5856
// Don't buffer stdio. We want output to appears in the log immediately
5957
config.buffered_stdio = 0;
6058
// Don't write bytecode; we can't modify the app bundle

0 commit comments

Comments
 (0)