This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Calls to platform._syscmd_ver() dependent functions consume STDIN
Type: behavior Stage: resolved
Components: Library (Lib), Windows Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: glukhov.k, miss-islington, pablogsal, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords: 3.9regression, patch

Created on 2021-07-06 16:21 by glukhov.k, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 27050 closed glukhov.k, 2021-07-07 05:58
PR 27092 merged glukhov.k, 2021-07-12 06:39
PR 27124 merged miss-islington, 2021-07-13 19:28
PR 27125 merged miss-islington, 2021-07-13 19:29
Messages (12)
msg397044 - (view) Author: Константин Глухов (glukhov.k) * Date: 2021-07-06 16:21
Starting with version 3.9.5 platform.win32* functions have been re-written and consume STDIN. The bug comes down to running 'ver', 'command /c ver', 'cmd /c ver' in platform._syscmd_ver() via subprocess.check_output().

The following code demonstrate the problem:

Python\396\python -c "import platform as p, sys;print(sys.stdin.tell());p.win32_ver();print(sys.stdin.tell())" < file
0
8000

All functions dependent on platform._syscmd_ver(), including platform.uname(), consume STDIN.

This behavior breaks all the scripts on Windows platform that have the calls mentioned above and use the following invocation:

python script.py < file
msg397052 - (view) Author: Константин Глухов (glukhov.k) * Date: 2021-07-06 19:14
The obvious fix is to add "stdin=subprocess.DEVNULL" argument to check_output() call.
msg397053 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2021-07-06 19:52
Would you like to create a pull request to that effect?
msg397055 - (view) Author: Константин Глухов (glukhov.k) * Date: 2021-07-06 20:10
I will try
msg397083 - (view) Author: Константин Глухов (glukhov.k) * Date: 2021-07-07 13:32
Well, I opened pull request, but it was closed. You guys have a very good team work going on out there :) Good luck!
msg397085 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2021-07-07 13:45
The pull request you opened was invalid, because it was just trying to merge the `main` branch of the python/cpython repository into the `3.9` branch.  What we need instead is a pull request between a branch from `main` in your own fork of python/cpython with the change you want to see in a new commit.  You can find a more detailed walkthrough in the devguide, or if you prefer to leave it for someone else to do that is also a valid option :)
msg397101 - (view) Author: Константин Глухов (glukhov.k) * Date: 2021-07-07 15:32
I do not understand why a one line change in the code requires full blown git clone. Shouldn't you guys have a system that allows to change code over the web interface and your bots will do the rest: checks, tests, regressions, etc.?
msg397103 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2021-07-07 15:47
You can make a PR entirely through the Github web interface, though we do generally encourage running the tests locally, especially since it would be good to add a new test for this case.
msg397439 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-07-13 19:21
New changeset 0ee0a740e12ec8568aafa033aa6bb08b265afe26 by Konstantin-Glukhov in branch 'main':
bpo-44572: On Windows, disconnect STDIN in platform._syscmd_ver() to prevent erroneous STDIN consumption (GH-27092)
https://github.com/python/cpython/commit/0ee0a740e12ec8568aafa033aa6bb08b265afe26
msg397444 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-07-13 19:48
New changeset 425756abdc03263ab3a52b068befd1ddb16c2dd2 by Miss Islington (bot) in branch '3.10':
bpo-44572: On Windows, disconnect STDIN in platform._syscmd_ver() to prevent erroneous STDIN consumption (GH-27092) (GH-27124)
https://github.com/python/cpython/commit/425756abdc03263ab3a52b068befd1ddb16c2dd2
msg397491 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-07-14 16:17
New changeset 5fc784e28ab9cd02c30395d1973ff825b787efa2 by Miss Islington (bot) in branch '3.9':
bpo-44572: On Windows, disconnect STDIN in platform._syscmd_ver() to prevent erroneous STDIN consumption (GH-27092)
https://github.com/python/cpython/commit/5fc784e28ab9cd02c30395d1973ff825b787efa2
msg397492 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-07-14 16:17
Thanks for the contribution!
History
Date User Action Args
2022-04-11 14:59:47adminsetgithub: 88738
2021-07-14 16:17:42steve.dowersetstatus: open -> closed
resolution: fixed
messages: + msg397492

stage: patch review -> resolved
2021-07-14 16:17:22steve.dowersetmessages: + msg397491
2021-07-13 19:48:32pablogsalsetnosy: + pablogsal
messages: + msg397444
2021-07-13 19:29:04miss-islingtonsetpull_requests: + pull_request25668
2021-07-13 19:28:58miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request25667
2021-07-13 19:21:56steve.dowersetmessages: + msg397439
2021-07-12 06:39:03glukhov.ksetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request25640
2021-07-07 15:47:42zach.waresetmessages: + msg397103
2021-07-07 15:32:56glukhov.ksetmessages: + msg397101
2021-07-07 13:45:03zach.waresetkeywords: + 3.9regression, - patch

messages: + msg397085
stage: patch review -> needs patch
2021-07-07 13:32:09glukhov.ksetmessages: + msg397083
2021-07-07 05:58:19glukhov.ksetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request25606
2021-07-06 20:10:23glukhov.ksetmessages: + msg397055
2021-07-06 19:52:42zach.waresetstage: needs patch
messages: + msg397053
components: - IO
versions: + Python 3.10, Python 3.11
2021-07-06 19:14:59glukhov.ksetmessages: + msg397052
2021-07-06 16:21:17glukhov.kcreate