Patchwork [4,of,8,py3-cleanup] run-tests: prefer PYTHON3 constant to many version_info checks (issue4668)

login
register
mail settings
Submitter Augie Fackler
Date May 18, 2015, 3:58 p.m.
Message ID <8a3bf2d5c27e977a9b2e.1431964723@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/9131/
State Accepted
Commit 3906b9783cd9d5d48c226d4e00b612c76d5526d5
Headers show

Comments

Augie Fackler - May 18, 2015, 3:58 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1431911833 14400
#      Sun May 17 21:17:13 2015 -0400
# Node ID 8a3bf2d5c27e977a9b2e262a8c885395590712af
# Parent  877c7818c6cfd08938627a76d3bb7731c6163a67
run-tests: prefer PYTHON3 constant to many version_info checks (issue4668)

We only support Python 2.6, 2.7, and 3.5 here, so we can simplify the
code and improve the warning.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -303,8 +303,9 @@  def parseargs(args, parser):
                 'warning: --timeout option ignored with --debug\n')
         options.timeout = 0
     if options.py3k_warnings:
-        if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0):
-            parser.error('--py3k-warnings can only be used on Python 2.6+')
+        if PYTHON3:
+            parser.error(
+                '--py3k-warnings can only be used on Python 2.6 and 2.7')
     if options.blacklist:
         options.blacklist = parselistfiles(options.blacklist, 'blacklist')
     if options.whitelist: