diff options
author | Marcus Müller <mmueller@gnuradio.org> | 2020-06-22 23:38:28 +0200 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2020-06-23 11:04:26 +0200 |
commit | 76b335dd8e4a01bd0e7d76a2be9912eeb41f36f2 (patch) | |
tree | ba6be95f8642d90fcfaf95d387f2b87450376842 | |
parent | 1e9a5be6de1efecbeddde08b39ebc1fda1a1786e (diff) |
blocktool: Monkeypatch time module for pygccxml to work under Python>=3.8
pygccxml tries to import time.clock, which was deprecated since Py3.3,
and removed in Py3.8
Thus, for these platforms:
time.clock = time.perf_counter
-rw-r--r-- | gr-utils/blocktool/core/parseheader.py | 6 | ||||
-rw-r--r-- | gr-utils/blocktool/core/parseheader_generic.py | 7 | ||||
-rw-r--r-- | gr-utils/blocktool/tests/test_blocktool.py | 8 |
3 files changed, 21 insertions, 0 deletions
diff --git a/gr-utils/blocktool/core/parseheader.py b/gr-utils/blocktool/core/parseheader.py index ef5d6d36ef..ac7f437961 100644 --- a/gr-utils/blocktool/core/parseheader.py +++ b/gr-utils/blocktool/core/parseheader.py @@ -18,6 +18,12 @@ import codecs import logging PYGCCXML_AVAILABLE = False +# ugly hack to make pygccxml work with Python >= 3.8 +import time +try: + time.clock +except: + time.clock = time.perf_counter try: from pygccxml import parser, declarations, utils PYGCCXML_AVAILABLE = True diff --git a/gr-utils/blocktool/core/parseheader_generic.py b/gr-utils/blocktool/core/parseheader_generic.py index ef6a1398ca..0aefe366fc 100644 --- a/gr-utils/blocktool/core/parseheader_generic.py +++ b/gr-utils/blocktool/core/parseheader_generic.py @@ -24,6 +24,13 @@ from ..core import Constants LOGGER = logging.getLogger(__name__) PYGCCXML_AVAILABLE = False +# ugly hack to make pygccxml work with Python >= 3.8 +import time +try: + time.clock +except: + time.clock = time.perf_counter + try: from pygccxml import parser, declarations, utils PYGCCXML_AVAILABLE = True diff --git a/gr-utils/blocktool/tests/test_blocktool.py b/gr-utils/blocktool/tests/test_blocktool.py index 8c8a1686b1..5712297bd7 100644 --- a/gr-utils/blocktool/tests/test_blocktool.py +++ b/gr-utils/blocktool/tests/test_blocktool.py @@ -15,6 +15,14 @@ from __future__ import unicode_literals import os import unittest import warnings + +# ugly hack to make pygccxml work with Python >= 3.8 +import time +try: + time.clock +except: + time.clock = time.perf_counter + try: import pygccxml SKIP_BLOCK_TEST = False |