Skip to content

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

Merged
vstinner merged 1 commit into
python:mainfrom
michael-o:sys.platform-freebsd-only
Jan 31, 2025
Merged

gh-129393: Make 'sys.platform' return "freebsd" only on FreeBSD witho…#129394
vstinner merged 1 commit into
python:mainfrom
michael-o:sys.platform-freebsd-only

Conversation

@michael-o

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

Copy link
Copy Markdown
Contributor

…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/

@ghost

ghost commented Jan 28, 2025

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

@michael-o

Copy link
Copy Markdown
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

encukou commented Jan 28, 2025

Copy link
Copy Markdown
Member

cc @vstinner as the FreeBSD contact

@emaste

emaste commented Jan 28, 2025

Copy link
Copy Markdown
Contributor

LGTM. Hopefully there's not too much fallout.

@michael-o

Copy link
Copy Markdown
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.

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@vstinner

Copy link
Copy Markdown
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
Copy Markdown
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

michael-o commented Jan 28, 2025

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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

michael-o commented Jan 28, 2025

Copy link
Copy Markdown
Contributor Author

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

emaste commented Jan 28, 2025

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
@vstinner

Copy link
Copy Markdown
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
Copy Markdown
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