-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Backport of PyConfig.use_system_logger
has changed ABI in a patch 3.13.1 -> 3.13.2
#130940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
PyConfig.use_system_logger
have changed public ABI in a patch on all maintained CPython versionsPyConfig.use_system_logger
have changed public ABI in a patch 3.13.1 -> 3.13.2
Correction: while #127592 lists a lot of backports, it looks like the backport was only ever applied to the 3.13 branch. So it is only 3.13.1 to 3.13.2 which has an ABI break across patch versions, 3.12 and older are unaffected. Will 3.13.3 revert this backport? |
ping @freakboy3742 as the author of the PR, maybe you have some context or opinion on the right path forward. |
PyConfig.use_system_logger
have changed public ABI in a patch 3.13.1 -> 3.13.2PyConfig.use_system_logger
has changed public ABI in a patch 3.13.1 -> 3.13.2
PyConfig.use_system_logger
has changed public ABI in a patch 3.13.1 -> 3.13.2PyConfig.use_system_logger
has changed ABI in a patch 3.13.1 -> 3.13.2
This does look like a breaking ABI change, but note that this only applies to iOS builds, due to the |
I believe it to be for all apple platforms, including macOS. https://developer.apple.com/library/archive/documentation/Porting/Conceptual/PortingUnix/compiling/compiling.html#//apple_ref/doc/uid/TP40002850-SW13 indicates |
Apologies for the breakage - that was definitely unintentional, and evidently slipped through the review process. Tagging @ned-deily for the macOS perspective; @Yhg1s for the 3.13 release impact. Confirming some other details in this thread:
By way of background - this patch was needed because of changes in Xcode 16 that broke the way we were capturing output for iOS testing. The core logic that is being enabled by the config flag is required for iOS testing to work. There's almost no use case for the flag to ever be disabled on iOS. However, it's entirely optional for macOS. It's a useful feature to have for very specific use cases (GUI apps that don't have a visible console), but there are other workarounds for that use case. At the very least, any impact on macOS can be reverted without impact. So - a complete reversion isn't possible without breaking all iOS testing; but there are some options. Firstly, we can revert the ABI-modifying changes to PyConfig. This doesn't need to be configurable in 3.13; we can treat this as a new 3.14 feature. That then leaves the question of how we handle not having access to the flag. On macOS, we can just ignore it - it's an optional feature, so we can just not enable the optional behavior on macOS. But on iOS, we've got a choice to make. One option would be to leave the code to enable the system logger in place, but only activate it in the testbed app. This would mean using a private API for the 3.13 version of the testbed - but then, if you squint, the iOS testbed is "internal" Python code? Maybe? A variant on this approach would be to migrate the system log handling code wholesale into the testbed, instead of it being in The other option would be to make the enabling the system logger the default behavior on iOS. This would be a change in behaviour for iOS - but it's arguably a much better default. Without enabling the system logger, stdout and stderr content are essentially swallowed at runtime. You can see stdout/stderr content in Xcode, but it won't appear in any system logs for a deployed app. This would also leave the door open for modifying 3.14 so that the default value for Of the three, the third option (change the default) would be my preferred option, as the end-state leaves iOS support in a much better place. However, I appreciate that it's a backwards incompatible change, so it's not a change that should be made lightly. I'm happy to work up the patch to fix this as soon as we've got agreement on the approach to take here. |
That's unfortunate that we didn't consider the 3.13.x ABI implications when reviewing this; sorry! For macOS, if I understand the implications correctly, the original change made would essentially only affect programs on macOS that embed Python 3.13 using an externally-provided shared-library (or framework) build of Python 3.13? If so, I would imagine there are very few such programs: since Python 3.13 isn't provided by the OS, I would expect most such programs would supply their own private copy of Python 3.13. I suppose it could be an issue for distributors like Homebrew or MacPorts or Conda but even there I would think it would be likely that both the embedding application and the Python 3.13.x version would be updated at the same time. So, for the next release of 3.13 (3.13.3), I guess the by-the-book thing to do would be to revert (and document the revert) the ABI change for macOS but, if my understanding is correct, the impact either way is likely to be very limited. For 3.14, an ABI change between 3.13.x and the initial release of 3.14 should be acceptable but perhaps taking another look at the changes while we are still in the alpha phase of the release cycle might be a good idea. Am I missing something? Perhaps @ronaldoussoren has an opinion? |
I've (tentatively) marked this as a blocker so we actually come to a decision before 3.13.3 and the 3.14 beta freeze. |
I designed PEP 741 "Python Configuration C API" to avoid such ABI issue. I implemented PEP 741 on Python 3.13 and older in the pythoncapi-compat project, but the implementation uses offsets of all |
IMO we should revert the PyConfig ABI to Python 3.13.0 ABI in the 3.13 branch. The newly added |
@pablogsal @encukou: ABI tests don't check for PyConfig members? |
They do, but they are run on Ubuntu. To catch platform-specific changes, we'd need to add dumps from all the platforms to the repo. |
It's a behavior change, but is it actually backwards incompatible? What could it break? Does sending stdout to the logger stop it from being visible in XCode? |
I agree - it's a very specific subset of explicit use, and a very limited window in which that use could have been adopted.
I'll admit my ignorance here - I had completely missed this PEP. It definitely looks like a big improvement though.
I'll make those two changes. It also provides an opportunity to update the testbed to use the new PyInitConfig API.
It would be backwards incompatible in that if you were relying on the default behavior (stdout not appearing in system logs), that would change. Would it break anything? Not unless you were relying on the literal content of the logs. Worse case would be "more content in the log than before". So - the outstanding question at this point is whether it's acceptable for the default behavior to be "use system logger" on 3.13 and/or 3.14. If it's not, then we'll need to explore other ways to enable logging in the testbed for 3.13. |
@vstinner I've been looking into updating the main branch to do this - but I feel like I'm missing something in the implementation. Unless I've missed one, all the current |
My sentence was for Python 3.13. In the main branch (Python 3.14), it's perfectly fine to use a PyConfig member: there is no ABI issue. I only proposed to convert the PyConfig member to a global variable in Python 3.13. But apparently, you decided to simply remove the member instead (without adding a global variable), I'm fine with it (it's up to you). |
My apologies - I misunderstood. To confirm the more general case - is it generally expected that, going forward, flags set with |
Currently, all PyConfig_Get/Set() options exist in Extract of PyConfig_Get() special path for if (strcmp(spec->name, "write_bytecode") == 0) {
int value;
if (config_get_sys_write_bytecode(config, &value) < 0) {
return NULL;
}
return PyBool_FromLong(value);
}
SPEC(module_search_paths, WSTR_LIST, PUBLIC, SYS_ATTR("path")), Moreover,
SPEC(write_bytecode, BOOL, PUBLIC, SYS_FLAG_SETTER(4, config_sys_flag_not)),
Also, Sadly, this option exists in 3 places:
|
That's it. The API design allows it, but there is no need yet to add options outside
At the ABI level, C extensions calling |
Corrected in #131129. |
… enable on iOS (#131172) Modify default behavior of use_system_log to enable on iOS.
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.
…er` to enable on iOS (python#131172) Modify default behavior of use_system_log to enable on iOS.
…er` to enable on iOS (python#131172) Modify default behavior of use_system_log to enable on iOS.
Bug report
Bug description:
In #127592 a new
PyConfig
flag was added for apple platforms to allow use of the system logger.This PR looks like it was backported to all branches from 3.9 through to 3.13, and has been released in 3.13.2
and 3.12.9.Unfortunately, this has changed the public ABI (layout of the
PyConfig
struct) on a patch release. This means that binaries using thePyConfig
API and built using 3.13.1 or 3.13.0(or 3.12.8)will potentially misbehave if running against a newer interpreter.I picked this up after getting a PyO3 "FFI check" failure on 3.13.2, reporting that our FFI bindings were no longer compatible with CPython.
In PEP 741 it was previously noted that backporting a flag to break the public ABI was decided against, so I believe this to be a bug.
Do I wait for CPython to revert this? Or do I make PyO3 adjust to the new ABI (and break compatibility with all existing interpreters)?
ping @vstinner as I know you have been very active on this API.
CPython versions tested on:
3.13
Operating systems tested on:
macOS
Linked PRs
PyConfig.use_system_logger
to enable on iOS #131172The text was updated successfully, but these errors were encountered: