From c487700ccd4cae873170b812c2f201f1400d8dea Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Thu, 30 Aug 2018 09:31:21 -0600 Subject: Do not use time.clock for Py3 in runtest time.clock is deprecated since Python 3.3 and will be removed in Python 3.8. 3.7 started issuing DeprecationWarning, which fails about 16 tests in AppVeyor CI (and running manually), since the warning appears in stderr stream and so real vs expected does not match any longer. Arguably the tests could be fixed to do a different check (contains rather than exactly-equal), but a change needs to be made anyway. use time.perf_counter as the time function for Python 3. This works for Windows and non-Windows; however since this function did not exist in 2.7 (added for 3.3), the Py2 case is left, which selects between time.clock and time.time depending on OS. Note this addresses runtest.py, but not code in bench/, which need attention also. Suggest that be a separate change since it's not failing tests. Signed-off-by: Mats Wichmann --- runtest.py | 12 ++++++++---- src/CHANGES.txt | 3 +++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/runtest.py b/runtest.py index 293e4ca..1cac45b 100755 --- a/runtest.py +++ b/runtest.py @@ -95,11 +95,12 @@ import time import threading try: # python3 from queue import Queue + PY3=True except ImportError as e: # python2 from Queue import Queue + PY3=False import subprocess - cwd = os.getcwd() baseline = 0 @@ -770,10 +771,13 @@ os.environ["python_executable"] = python # but time.time() does a better job on Linux systems, so let that be # the non-Windows default. -if sys.platform == 'win32': - time_func = time.clock +if PY3: + time_func = time.perf_counter else: - time_func = time.time + if sys.platform == 'win32': + time_func = time.clock + else: + time_func = time.time if print_times: print_time_func = lambda fmt, time: sys.stdout.write(fmt % time) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index ab15214..27fe66a 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -123,6 +123,9 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE - fix must_contain tests for py3 - one swig test now checks for Python.h instead of failing - if test opens os.devnull, register with atexit so file opens do not leak. + - for py3, use time.perf_counter instead of depr time.clock, which is + used in win32 case for py2. py37 depr warnings were failing a bunch + of tests on windows since warn messes up expected stderr. From Hao Wu - typo in customized decider example in user guide -- cgit v0.12 From b215cbc5022148bff6fe6986780794fa80e75b2b Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Thu, 30 Aug 2018 10:48:27 -0600 Subject: Rework the time.clock -> time.perf_counter change Signed-off-by: Mats Wichmann --- runtest.py | 5 ++--- src/CHANGES.txt | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/runtest.py b/runtest.py index 1cac45b..697b872 100755 --- a/runtest.py +++ b/runtest.py @@ -95,10 +95,8 @@ import time import threading try: # python3 from queue import Queue - PY3=True except ImportError as e: # python2 from Queue import Queue - PY3=False import subprocess cwd = os.getcwd() @@ -771,7 +769,8 @@ os.environ["python_executable"] = python # but time.time() does a better job on Linux systems, so let that be # the non-Windows default. -if PY3: +#TODO: clean up when py2 support is dropped +try: time_func = time.perf_counter else: if sys.platform == 'win32': diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 27fe66a..d81a9f9 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -123,9 +123,10 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE - fix must_contain tests for py3 - one swig test now checks for Python.h instead of failing - if test opens os.devnull, register with atexit so file opens do not leak. - - for py3, use time.perf_counter instead of depr time.clock, which is - used in win32 case for py2. py37 depr warnings were failing a bunch - of tests on windows since warn messes up expected stderr. + - use time.perf_counter instead of time.clock if it exists. + time.clock deprecated since py3.3, due to remove in 3.8. deprecation + warnings from py3.7 were failing a bunch of tests on Windows since they + mess up expected stderr. From Hao Wu - typo in customized decider example in user guide -- cgit v0.12 From 4913b28bfc6738f49241113202ce1be02bbe9368 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Thu, 30 Aug 2018 11:34:19 -0600 Subject: Part of previous change restored somehow the change from if test to try block got partly lost during commit. changing else->except --- runtest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtest.py b/runtest.py index 697b872..45ffffc 100755 --- a/runtest.py +++ b/runtest.py @@ -772,7 +772,7 @@ os.environ["python_executable"] = python #TODO: clean up when py2 support is dropped try: time_func = time.perf_counter -else: +except AttributeError: if sys.platform == 'win32': time_func = time.clock else: -- cgit v0.12 From 40982e03a34d869900d6ae2201c19cbdcf9a6d6f Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 30 Aug 2018 18:38:25 -0700 Subject: see if defining _JAVA_OPTIONS= to nothing will quiet STDERR from java which is breaking tests for py3.7 --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8894823..3ee530e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,7 +37,9 @@ jobs: - <<: *test_job python: 3.7 - env: PYVER=37 + env: + - PYVER=37 + - _JAVA_OPTIONS= sudo: required dist: xenial # required for Python 3.7 (travis-ci/travis-ci#9069) -- cgit v0.12