From: Serhiy Storchaka Date: Thu, 11 Jul 2013 17:01:17 +0000 (+0300) Subject: Issue #18338: `python --version` now prints version string to stdout, and X-Git-Tag: v3.4.0a1~260 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3ed4edb94cadaef747f6032c52cd903a169883e;p=python Issue #18338: `python --version` now prints version string to stdout, and not to stderr. Patch by Berker Peksag and Michael Dickens. --- diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index 1270ce3f3d..3fa8ade466 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -41,8 +41,10 @@ class CmdLineTest(unittest.TestCase): def test_version(self): version = ('Python %d.%d' % sys.version_info[:2]).encode("ascii") - rc, out, err = assert_python_ok('-V') - self.assertTrue(err.startswith(version)) + for switch in '-V', '--version': + rc, out, err = assert_python_ok(switch) + self.assertFalse(err.startswith(version)) + self.assertTrue(out.startswith(version)) def test_verbose(self): # -v causes imports to write to stderr. If the write to diff --git a/Misc/NEWS b/Misc/NEWS index 96e51e38fb..e62f05a42a 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1? Core and Builtins ----------------- +- Issue #18338: `python --version` now prints version string to stdout, and + not to stderr. Patch by Berker Peksag and Michael Dickens. + - Issue #18426: Fix NULL pointer dereference in C extension import when PyModule_GetDef() returns an error. diff --git a/Modules/main.c b/Modules/main.c index af0d7f4064..0343ddab6e 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -500,7 +500,7 @@ Py_Main(int argc, wchar_t **argv) return usage(0, argv[0]); if (version) { - fprintf(stderr, "Python %s\n", PY_VERSION); + printf("Python %s\n", PY_VERSION); return 0; }