Skip to content

Fix python3 sys.platform check for Linux#15727

Merged
andrewkroh merged 1 commit intoelastic:feature/python3from
andrewkroh:feature/python3-auditbeat-fix
Jan 22, 2020
Merged

Fix python3 sys.platform check for Linux#15727
andrewkroh merged 1 commit intoelastic:feature/python3from
andrewkroh:feature/python3-auditbeat-fix

Conversation

@andrewkroh
Copy link
Copy Markdown
Member

On Linux, sys.platform doesn’t contain the major version anymore. It is now always ‘linux’, instead of ‘linux2’ or ‘linux3’ depending on the Linux version used to build Python. Replace sys.platform == ‘linux2’ with sys.platform.startswith(‘linux’), or directly sys.platform == ‘linux’ if you don’t need to support older Python versions.

Ref: https://docs.python.org/3.3/whatsnew/3.3.html#porting-python-code

On Linux, sys.platform doesn’t contain the major version anymore. It is now always ‘linux’, instead of ‘linux2’ or ‘linux3’ depending on the Linux version used to build Python. Replace sys.platform == ‘linux2’ with sys.platform.startswith(‘linux’), or directly sys.platform == ‘linux’ if you don’t need to support older Python versions.

Ref: https://docs.python.org/3.3/whatsnew/3.3.html#porting-python-code
@andrewkroh andrewkroh requested a review from a team as a code owner January 22, 2020 02:36
@jsoriano jsoriano mentioned this pull request Jan 22, 2020
63 tasks
Copy link
Copy Markdown
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

Good catch.

@andrewkroh andrewkroh merged commit d037668 into elastic:feature/python3 Jan 22, 2020
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
On Linux, sys.platform doesn’t contain the major version anymore. It is now always ‘linux’, instead of ‘linux2’ or ‘linux3’ depending on the Linux version used to build Python. Replace sys.platform == ‘linux2’ with sys.platform.startswith(‘linux’), or directly sys.platform == ‘linux’ if you don’t need to support older Python versions.

Ref: https://docs.python.org/3.3/whatsnew/3.3.html#porting-python-code
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.

2 participants