]> granicus.if.org Git - python/commitdiff
Issue #28532: Show sys.version when -V option is supplied twice
authorINADA Naoki <songofacandy@gmail.com>
Mon, 21 Nov 2016 11:57:14 +0000 (20:57 +0900)
committerINADA Naoki <songofacandy@gmail.com>
Mon, 21 Nov 2016 11:57:14 +0000 (20:57 +0900)
Doc/using/cmdline.rst
Lib/test/test_cmd_line.py
Misc/NEWS
Misc/python.man
Modules/main.c

index 81b08236181ceaa6c77bd574a27fe3a2824dcd6f..7ebdb95984d223aba9340287730f8ec060e92213 100644 (file)
@@ -180,7 +180,12 @@ Generic options
 
    Print the Python version number and exit.  Example output could be::
 
-       Python 3.0
+       Python 3.6.0b2+
+
+   When given twice, print more information about the build, like::
+
+       Python 3.6.0b2+ (3.6:84a3c5003510+, Oct 26 2016, 02:33:55)
+       [GCC 6.2.0 20161005]
 
 
 .. _using-on-misc-options:
index 87571d3073dece49f4e714ce0f867c7ecf688c33..b71bb9f7ee5b15f0b4d7171c26e687ee440a4f34 100644 (file)
@@ -43,7 +43,7 @@ class CmdLineTest(unittest.TestCase):
 
     def test_version(self):
         version = ('Python %d.%d' % sys.version_info[:2]).encode("ascii")
-        for switch in '-V', '--version':
+        for switch in '-V', '--version', '-VV':
             rc, out, err = assert_python_ok(switch)
             self.assertFalse(err.startswith(version))
             self.assertTrue(out.startswith(version))
index 435fd0afcdb15428b64e35ea246c0f19016bd1c1..7ba6b427700486f5f7cbcdeeff33893440bd9e6d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@ What's New in Python 3.6.0 beta 4
 Core and Builtins
 -----------------
 
+- Issue #28532: Show sys.version when -V option is supplied twice.
+
 - Issue #28746: Fix the set_inheritable() file descriptor method on platforms
   that do not have the ioctl FIOCLEX and FIONCLEX commands.
 
index 28f19b68a763f26818b4adcaaaa385bcab27d3be..385b6546c8a52be13df5f7c17a144f8d154d0448 100644 (file)
@@ -194,7 +194,8 @@ searching for a module.  Also provides information on module cleanup
 at exit.
 .TP
 .B \-V ", " \-\-version
-Prints the Python version number of the executable and exits.
+Prints the Python version number of the executable and exits.  When given
+twice, print more information about the build.
 .TP
 .BI "\-W " argument
 Warning control.  Python sometimes prints warning message to
index 6986d94b42d2526510b607e8f27ff0802788d6b5..d75f64a65f30580f76fb10df5a40b8be0200e19d 100644 (file)
@@ -74,6 +74,7 @@ static const char usage_3[] = "\
 -v     : verbose (trace import statements); also PYTHONVERBOSE=x\n\
          can be supplied multiple times to increase verbosity\n\
 -V     : print the Python version number and exit (also --version)\n\
+         when given twice, print more information about the build\n\
 -W arg : warning control; arg is action:message:category:module:lineno\n\
          also PYTHONWARNINGS=arg\n\
 -x     : skip first line of source, allowing use of non-Unix forms of #!cmd\n\
@@ -512,7 +513,7 @@ Py_Main(int argc, wchar_t **argv)
         return usage(0, argv[0]);
 
     if (version) {
-        printf("Python %s\n", PY_VERSION);
+        printf("Python %s\n", version >= 2 ? Py_GetVersion() : PY_VERSION);
         return 0;
     }