Skip to content
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

gh-129393: Make 'sys.platform' return "freebsd" only on FreeBSD witho… #129394

Merged
merged 1 commit into from
Jan 31, 2025

Conversation

michael-o
Copy link
Contributor

@michael-o michael-o commented Jan 28, 2025

…ut major version

Result:

osipovmi@deblndw011x:~/var/Projekte/cpython (main *+>)
$ /tmp/python-3.13/bin/python3
Python 3.14.0a4+ (heads/main-dirty:8e57877e3f4, Jan 28 2025, 10:01:48) [Clang 19.1.5 (https://github.com/llvm/llvm-project.git llvmorg-19.1.5-0-gab4b5a on freebsd
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.platform
'freebsd'
>>>

📚 Documentation preview 📚: https://cpython-previews--129394.org.readthedocs.build/

Copy link

cpython-cla-bot bot commented Jan 28, 2025

All commit authors signed the Contributor License Agreement.
CLA signed

@michael-o
Copy link
Contributor Author

FWIW: I am a FreeBSD committer as well.

@emaste

@michael-o michael-o force-pushed the sys.platform-freebsd-only branch from 7cecc55 to 242840a Compare January 28, 2025 09:31
@encukou
Copy link
Member

encukou commented Jan 28, 2025

cc @vstinner as the FreeBSD contact

@emaste
Copy link
Contributor

emaste commented Jan 28, 2025

LGTM. Hopefully there's not too much fallout.

@michael-o
Copy link
Contributor Author

LGTM. Hopefully there's not too much fallout.

Me as well, but this should stay on 3.14 and not be backported, even if I'd like to see that.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vstinner
Copy link
Member

IMO this change is backward compatible since it was recommended to use sys.platform.startswith('freebsd') to check if Python is running on FreeBSD. This code remains correct is sys.platform becomes "freebsd".

@vstinner
Copy link
Member

We did the same change on Linux when Linux was upgrade from Linux 2.x to Linux 3.x, and it went fine.

@michael-o
Copy link
Contributor Author

michael-o commented Jan 28, 2025

IMO this change is backward compatible since it was recommended to use sys.platform.startswith('freebsd') to check if Python is running on FreeBSD. This code remains correct is sys.platform becomes "freebsd".

Oh great, I'd love to see this backported!

@michael-o michael-o force-pushed the sys.platform-freebsd-only branch from 242840a to b9062bb Compare January 28, 2025 14:59
@vstinner
Copy link
Member

Oh great, I'd love to see this backported!

That would be backward incompatible, it's a bad idea. This change can only land into Python 3.14.

@michael-o
Copy link
Contributor Author

michael-o commented Jan 28, 2025

Oh great, I'd love to see this backported!

That would be backward incompatible, it's a bad idea. This change can only land into Python 3.14.

I am confused, doesn't this contract your previous statement: #129394 (comment)?

@emaste
Copy link
Contributor

emaste commented Jan 28, 2025

Code "should" be checking startswith but I'd wager there are there cases that use the full string; they shouldn't be broken in an existing release.

@michael-o
Copy link
Contributor Author

Code "should" be checking startswith but I'd wager there are there cases that use the full string; they shouldn't be broken in an existing release.

That's correct and this is what I have noticed with pyproject.toml.

@michael-o
Copy link
Contributor Author

Is there anything required from me to merge this one?

@michael-o michael-o force-pushed the sys.platform-freebsd-only branch from b9062bb to 0f19207 Compare January 28, 2025 19:45
@vstinner vstinner merged commit e3eba8c into python:main Jan 31, 2025
41 checks passed
@vstinner
Copy link
Member

Merged, thank you @michael-o.

@michael-o michael-o deleted the sys.platform-freebsd-only branch January 31, 2025 10:05
@michael-o
Copy link
Contributor Author

Merged, thank you @michael-o.

Thank you very much for the quick turnaround. Always a pleasure to work with pros!

srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Feb 7, 2025
…python#129394)

Make 'sys.platform' return "freebsd" only on FreeBSD without major version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants