Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e3ed4ed

Browse files
Issue #18338: python --version now prints version string to stdout, and
not to stderr. Patch by Berker Peksag and Michael Dickens.
1 parent e173d01 commit e3ed4ed

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

Lib/test/test_cmd_line.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ def test_usage(self):
4141

4242
def test_version(self):
4343
version = ('Python %d.%d' % sys.version_info[:2]).encode("ascii")
44-
rc, out, err = assert_python_ok('-V')
45-
self.assertTrue(err.startswith(version))
44+
for switch in '-V', '--version':
45+
rc, out, err = assert_python_ok(switch)
46+
self.assertFalse(err.startswith(version))
47+
self.assertTrue(out.startswith(version))
4648

4749
def test_verbose(self):
4850
# -v causes imports to write to stderr. If the write to

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #18338: `python --version` now prints version string to stdout, and
14+
not to stderr. Patch by Berker Peksag and Michael Dickens.
15+
1316
- Issue #18426: Fix NULL pointer dereference in C extension import when
1417
PyModule_GetDef() returns an error.
1518

Modules/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ Py_Main(int argc, wchar_t **argv)
500500
return usage(0, argv[0]);
501501

502502
if (version) {
503-
fprintf(stderr, "Python %s\n", PY_VERSION);
503+
printf("Python %s\n", PY_VERSION);
504504
return 0;
505505
}
506506

0 commit comments

Comments
 (0)