summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINADA Naoki <songofacandy@gmail.com>2016-11-21 20:57:14 +0900
committerINADA Naoki <songofacandy@gmail.com>2016-11-21 20:57:14 +0900
commit457668cddd4cb03d8ae6865ec49c3d7ffe9a8da8 (patch)
tree5c37d7c5050cb4be0ea86cf0edeef14771c4d6a1
parentcaa9594a88c5a8e69fad4d00f0583a8e6e99b461 (diff)
downloadcpython-457668cddd4cb03d8ae6865ec49c3d7ffe9a8da8.tar.gz
Issue #28532: Show sys.version when -V option is supplied twice
-rw-r--r--Doc/using/cmdline.rst7
-rw-r--r--Lib/test/test_cmd_line.py2
-rw-r--r--Misc/NEWS2
-rw-r--r--Misc/python.man3
-rw-r--r--Modules/main.c3
5 files changed, 13 insertions, 4 deletions
diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst
index 81b0823618..7ebdb95984 100644
--- a/Doc/using/cmdline.rst
+++ b/Doc/using/cmdline.rst
@@ -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:
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index 87571d3073..b71bb9f7ee 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -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))
diff --git a/Misc/NEWS b/Misc/NEWS
index 435fd0afcd..7ba6b42770 100644
--- 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.
diff --git a/Misc/python.man b/Misc/python.man
index 28f19b68a7..385b6546c8 100644
--- a/Misc/python.man
+++ b/Misc/python.man
@@ -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
diff --git a/Modules/main.c b/Modules/main.c
index 6986d94b42..d75f64a65f 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -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;
}