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

Skip to content

Commit 0e175a6

Browse files
committed
Issue #28532: Show sys.version when -V option is supplied twice
1 parent 6befb64 commit 0e175a6

5 files changed

Lines changed: 13 additions & 4 deletions

File tree

Doc/using/cmdline.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,12 @@ Generic options
180180

181181
Print the Python version number and exit. Example output could be::
182182

183-
Python 3.0
183+
Python 3.6.0b2+
184+
185+
When given twice, print more information about the build, like::
186+
187+
Python 3.6.0b2+ (3.6:84a3c5003510+, Oct 26 2016, 02:33:55)
188+
[GCC 6.2.0 20161005]
184189

185190

186191
.. _using-on-misc-options:

Lib/test/test_cmd_line.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_usage(self):
4343

4444
def test_version(self):
4545
version = ('Python %d.%d' % sys.version_info[:2]).encode("ascii")
46-
for switch in '-V', '--version':
46+
for switch in '-V', '--version', '-VV':
4747
rc, out, err = assert_python_ok(switch)
4848
self.assertFalse(err.startswith(version))
4949
self.assertTrue(out.startswith(version))

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ What's New in Python 3.6.0 beta 4
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #28532: Show sys.version when -V option is supplied twice.
14+
1315
- Issue #28746: Fix the set_inheritable() file descriptor method on platforms
1416
that do not have the ioctl FIOCLEX and FIONCLEX commands.
1517

Misc/python.man

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ searching for a module. Also provides information on module cleanup
194194
at exit.
195195
.TP
196196
.B \-V ", " \-\-version
197-
Prints the Python version number of the executable and exits.
197+
Prints the Python version number of the executable and exits. When given
198+
twice, print more information about the build.
198199
.TP
199200
.BI "\-W " argument
200201
Warning control. Python sometimes prints warning message to

Modules/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ static const char usage_3[] = "\
7474
-v : verbose (trace import statements); also PYTHONVERBOSE=x\n\
7575
can be supplied multiple times to increase verbosity\n\
7676
-V : print the Python version number and exit (also --version)\n\
77+
when given twice, print more information about the build\n\
7778
-W arg : warning control; arg is action:message:category:module:lineno\n\
7879
also PYTHONWARNINGS=arg\n\
7980
-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)
512513
return usage(0, argv[0]);
513514

514515
if (version) {
515-
printf("Python %s\n", PY_VERSION);
516+
printf("Python %s\n", version >= 2 ? Py_GetVersion() : PY_VERSION);
516517
return 0;
517518
}
518519

0 commit comments

Comments
 (0)