Skip to content

Commit 1e27c13

Browse files
committed
[3.10] pythongh-130940: Remove PyConfig.use_system_logger (python#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 531dd43 commit 1e27c13

8 files changed

Lines changed: 19 additions & 52 deletions

File tree

‎Doc/c-api/init_config.rst‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,17 +1101,6 @@ PyConfig
11011101
11021102
Default: ``1`` in Python config and ``0`` in isolated config.
11031103
1104-
.. c:member:: int use_system_logger
1105-
1106-
If non-zero, ``stdout`` and ``stderr`` will be redirected to the system
1107-
log.
1108-
1109-
Only available on macOS 10.12 and later, and on iOS.
1110-
1111-
Default: ``0`` (don't use system log).
1112-
1113-
.. versionadded:: 3.13.2
1114-
11151104
.. c:member:: int user_site_directory
11161105
11171106
If non-zero, add the user site directory to :data:`sys.path`.

‎Include/cpython/initconfig.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,6 @@ typedef struct PyConfig {
173173
int legacy_windows_stdio;
174174
#endif
175175
wchar_t *check_hash_pycs_mode;
176-
#ifdef __APPLE__
177-
int use_system_logger;
178-
#endif
179176

180177
/* --- Path configuration inputs ------------ */
181178
int pathconfig_warnings;

‎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
@@ -439,8 +439,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
439439
CONFIG_COMPAT.update({
440440
'legacy_windows_stdio': 0,
441441
})
442-
if support.is_apple:
443-
CONFIG_COMPAT['use_system_logger'] = False
444442

445443
CONFIG_PYTHON = dict(CONFIG_COMPAT,
446444
_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 & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,6 @@ config_check_consistency(const PyConfig *config)
644644
assert(config->check_hash_pycs_mode != NULL);
645645
assert(config->_install_importlib >= 0);
646646
assert(config->pathconfig_warnings >= 0);
647-
#ifdef __APPLE__
648-
assert(config->use_system_logger >= 0);
649-
#endif
650647
return 1;
651648
}
652649
#endif
@@ -731,9 +728,6 @@ _PyConfig_InitCompatConfig(PyConfig *config)
731728
#ifdef MS_WINDOWS
732729
config->legacy_windows_stdio = -1;
733730
#endif
734-
#ifdef __APPLE__
735-
config->use_system_logger = 0;
736-
#endif
737731
}
738732

739733
/* Excluded from public struct PyConfig for backporting reasons. */
@@ -763,9 +757,6 @@ config_init_defaults(PyConfig *config)
763757
#ifdef MS_WINDOWS
764758
config->legacy_windows_stdio = 0;
765759
#endif
766-
#ifdef __APPLE__
767-
config->use_system_logger = 0;
768-
#endif
769760
}
770761

771762

@@ -798,9 +789,6 @@ PyConfig_InitIsolatedConfig(PyConfig *config)
798789
#ifdef MS_WINDOWS
799790
config->legacy_windows_stdio = 0;
800791
#endif
801-
#ifdef __APPLE__
802-
config->use_system_logger = 0;
803-
#endif
804792
}
805793

806794

‎Python/pylifecycle.c‎

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,15 @@
2222
# include <TargetConditionals.h>
2323
# include <mach-o/loader.h>
2424
// The os_log unified logging APIs were introduced in macOS 10.12, iOS 10.0,
25-
// tvOS 10.0, and watchOS 3.0;
25+
// tvOS 10.0, and watchOS 3.0; we enable the use of the system logger
26+
// automatically on non-macOS platforms.
2627
# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
27-
# define HAS_APPLE_SYSTEM_LOG 1
28-
# elif defined(TARGET_OS_OSX) && TARGET_OS_OSX
29-
# if defined(MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
30-
# define HAS_APPLE_SYSTEM_LOG 1
31-
# else
32-
# define HAS_APPLE_SYSTEM_LOG 0
33-
# endif
28+
# define USE_APPLE_SYSTEM_LOG 1
3429
# else
35-
# define HAS_APPLE_SYSTEM_LOG 0
30+
# define USE_APPLE_SYSTEM_LOG 0
3631
# endif
3732

38-
# if HAS_APPLE_SYSTEM_LOG
33+
# if USE_APPLE_SYSTEM_LOG
3934
# include <os/log.h>
4035
# endif
4136
#endif
@@ -77,7 +72,7 @@ static PyStatus add_main_module(PyInterpreterState *interp);
7772
static PyStatus init_import_site(void);
7873
static PyStatus init_set_builtins_open(void);
7974
static PyStatus init_sys_streams(PyThreadState *tstate);
80-
#if defined(__APPLE__) && HAS_APPLE_SYSTEM_LOG
75+
#if defined(__APPLE__) && USE_APPLE_SYSTEM_LOG
8176
static PyStatus init_apple_streams(PyThreadState *tstate);
8277
#endif
8378
static void wait_for_thread_shutdown(PyThreadState *tstate);
@@ -1148,12 +1143,10 @@ init_interp_main(PyThreadState *tstate)
11481143
return status;
11491144
}
11501145

1151-
#if defined(__APPLE__) && HAS_APPLE_SYSTEM_LOG
1152-
if (config->use_system_logger) {
1153-
status = init_apple_streams(tstate);
1154-
if (_PyStatus_EXCEPTION(status)) {
1155-
return status;
1156-
}
1146+
#if defined(__APPLE__) && USE_APPLE_SYSTEM_LOG
1147+
status = init_apple_streams(tstate);
1148+
if (_PyStatus_EXCEPTION(status)) {
1149+
return status;
11571150
}
11581151
#endif
11591152

@@ -2443,7 +2436,7 @@ init_sys_streams(PyThreadState *tstate)
24432436
return res;
24442437
}
24452438

2446-
#if defined(__APPLE__) && HAS_APPLE_SYSTEM_LOG
2439+
#if defined(__APPLE__) && USE_APPLE_SYSTEM_LOG
24472440

24482441
static PyObject *
24492442
apple_log_write_impl(PyObject *self, PyObject *args)
@@ -2504,7 +2497,7 @@ init_apple_streams(PyThreadState *tstate)
25042497
return status;
25052498
}
25062499

2507-
#endif // __APPLE__ && HAS_APPLE_SYSTEM_LOG
2500+
#endif // __APPLE__ && USE_APPLE_SYSTEM_LOG
25082501

25092502

25102503
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)