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
This commit is contained in:
parent
daeec838fe
commit
56c7fd9871
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user