-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-43284: Update platform.win32_ver to use platform._syscmd_ver instead of sys.getwindowsversion().platform_version for determining accurate Windows version #25500
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
Conversation
Co-authored-by: Eryk Sun <[email protected]>
I also noticed that try:
ints = map(int, l)
except ValueError:
strings = l
else:
strings = list(map(str, ints)) The |
Are you suggesting to make the change in this PR itself? |
Yes, please. (They don't exist, but any tests for these cases would be breaking on your PR because you've reintroduced the call to that function.) |
Change applied. |
Co-authored-by: Steve Dower <[email protected]>
I also noticed something that can cause naming conflicts later. In the function win32_ver the minor version is stored in a variable named |
If you'd like to make more changes, go ahead. Just let us know when it's ready. |
Ok |
PR is ready for reviewing and if applicable then merging. (No more commits will be made) |
Thanks @shreyanavigyan for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
Thanks @shreyanavigyan for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
GH-25523 is a backport of this pull request to the 3.9 branch. |
…s.getwindowsversion() (pythonGH-25500) The sys module uses the kernel32.dll version number, which can vary from the "actual" Windows version. Since the best option for getting the version is WMI (which is expensive), we switch back to launching cmd.exe (which is also expensive, but a lot less code on our part). sys.getwindowsversion() is not updated to avoid launching executables from that module. (cherry picked from commit 2a3f489) Co-authored-by: Shreyan Avigyan <[email protected]>
…s.getwindowsversion() (pythonGH-25500) The sys module uses the kernel32.dll version number, which can vary from the "actual" Windows version. Since the best option for getting the version is WMI (which is expensive), we switch back to launching cmd.exe (which is also expensive, but a lot less code on our part). sys.getwindowsversion() is not updated to avoid launching executables from that module. (cherry picked from commit 2a3f489) Co-authored-by: Shreyan Avigyan <[email protected]>
GH-25524 is a backport of this pull request to the 3.8 branch. |
…s.getwindowsversion() (GH-25500) The sys module uses the kernel32.dll version number, which can vary from the "actual" Windows version. Since the best option for getting the version is WMI (which is expensive), we switch back to launching cmd.exe (which is also expensive, but a lot less code on our part). sys.getwindowsversion() is not updated to avoid launching executables from that module. (cherry picked from commit 2a3f489) Co-authored-by: Shreyan Avigyan <[email protected]>
…s.getwindowsversion() (GH-25500) The sys module uses the kernel32.dll version number, which can vary from the "actual" Windows version. Since the best option for getting the version is WMI (which is expensive), we switch back to launching cmd.exe (which is also expensive, but a lot less code on our part). sys.getwindowsversion() is not updated to avoid launching executables from that module. (cherry picked from commit 2a3f489) Co-authored-by: Shreyan Avigyan <[email protected]>
calling shell command may lead to security vulnerability. I'm strongly against this. I'm implementing a cpython wrapper that would disable methods like IMO https://bugs.python.org/issue43284 is the expected behavior. The process is running in compatible mode, so an old version was reported. If you want the exact version, you should disable compatible mode. |
In linux platform.system() also calls external command |
Running the Anyway, stating with Python 3.12 you'll probably be happy to discover that
The platform module is intended to return information about the machine and installed operating system, for logging and such. On Windows, scripts should use |
Python should provide an option to disable external commands, just like PHP does. It's not only about hacking env variables, but also raises risks when string injection occurs. In my code I use C# to call python functions, which are user functions providing trading algorithms. But I don't want these user functions to call any external commands. Right now if I detect and prevent external command calls, packages like pandas/numpy would fail because they are calling platform.system(), which in turn calls external commands. |
platform.win32_ver
derives the Windows version fromsys.getwindowsversion().platform_version
which in turn derives the version fromkernel32.dll
(which can be of a different version than Windows itself). Therefore this PR updates theplatform.win32_ver
to determine the version using theplatform
module's_syscmd_ver
private function to return an accurate version.More discussions are held at: https://bugs.python.org/issue43284
https://bugs.python.org/issue43284