From 56c7fd9871f10addbf4456faf1ac8d7270996009 Mon Sep 17 00:00:00 2001 From: Iryna Shcherbina Date: Tue, 13 Feb 2018 13:49:21 +0100 Subject: [PATCH] Fix deprecation warning on using imp In build log fixes the following warning: /builddir/build/SOURCES/check-pyc-and-pyo-timestamps.py:3: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses import imp --- check-pyc-and-pyo-timestamps.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/check-pyc-and-pyo-timestamps.py b/check-pyc-and-pyo-timestamps.py index 76a3421..262a985 100644 --- a/check-pyc-and-pyo-timestamps.py +++ b/check-pyc-and-pyo-timestamps.py @@ -1,6 +1,6 @@ """Checks if all *.pyc and *.pyo files have later mtime than their *.py files.""" -import imp +import importlib.util import os import sys @@ -37,16 +37,18 @@ not_compiled = [ ] failed = 0 + def bytecode_expected(source): for f in not_compiled: if source.endswith(f): return False return True + compiled = filter(lambda f: bytecode_expected(f), sys.argv[1:]) for f in compiled: # check both pyo and pyc - to_check = map(lambda b: imp.cache_from_source(f, b), (True, False)) + to_check = map(lambda b: importlib.util.cache_from_source(f, b), (True, False)) f_mtime = os.path.getmtime(f) for c in to_check: c_mtime = os.path.getmtime(c)