]> granicus.if.org Git - python/commitdiff
Issue #18338: `python --version` now prints version string to stdout, and
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 11 Jul 2013 17:01:17 +0000 (20:01 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Thu, 11 Jul 2013 17:01:17 +0000 (20:01 +0300)
not to stderr.  Patch by Berker Peksag and Michael Dickens.

Lib/test/test_cmd_line.py
Misc/NEWS
Modules/main.c

index 1270ce3f3d58c04440aa6ebae2cce6fea33cb49e..3fa8ade4668aa19c6ad87e07a930d6a5f98eb182 100644 (file)
@@ -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
index 96e51e38fbfcca32dfd129f14d10fbe5a16d660b..e62f05a42a9bb30ebc806ea23f06548678af4bf7 100644 (file)
--- 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.
 
index af0d7f40641f7117da878385a9698b9ee276fcd6..0343ddab6e9133d69738e6bdee6e3d34c714c97e 100644 (file)
@@ -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;
     }