Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break on older macOS versions (essentially any macOS version that predates the existence of iPhone) because
TARGET_OS_OSXdoesn't exist. However, on all versions of iOS,TARGET_OS_OSXwill exist with a value of 0. So - my suggested approach here would be:I can see there's a couple of other places (L99 of this file; L352 of pycore_eval.h) where an analogous change would be required.
I guess the other option would be to modify the code that sets
TARGET_OS_OSXfrom:to
This works because
TARGET_OS_IPHONEis any Apple mobile device (iOS, tvOS, watchOS, visionOS);TARGET_OS_IOSis specifically an iPhone/iPad. However, futzing withTARGET_OS_OSXseems like asking for trouble, so the explicit approach would be my preferred option.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you may be missing the context that this file is importing this header where we are doing the dance:
cpython/Include/internal/pycore_ceval.h
Lines 350 to 360 in 0dbaeb9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - I did miss that import would be in effect. Given that imported definition, the form you've got in the PR at present should work - but it still makes me a bit twitchy because it's redefining an Apple-provided constant that has otherwise well defined behavior.
This is essentially what bit me here - the logic didn't make sense because I didn't notice the import where the behavior of the Apple-provided constant was being redefined). We've also had examples in the past where someone adds/removes an import of an otherwise unrelated file, and suddenly things break because that file has redefined basic platform constants (or has removed an import that was making those constants work in a predictable way).
If we're going to go down the path of redefining the constant, it might be worth looking at a top-level replacement for
TargetConditionals.hthat uses those base definitions and ensures they're consistently defined (so we don't need to do thedefined(TARGET_OS_OSX) && TARGET_OS_OSXdance everywhere) - but that's a much bigger set of changes, and then comes with the overhead of making sure that everyone remembers to use the updated definitions, rather than importingTargetConditionals.h.So - call my preference for using the definitions-as-provided a "strong opinion, weakly held". With the indentation nitpick flagged in
pycore_ceval.h, I can live with this as-is.