Bug 1669471 - Get rid of `DeprecationWarning` in `file_generate.py` r=firefox-build-system-reviewers,mhentges

`imp` is deprecated since Python 3.4 and later Python versions are very noisy about printing `DeprecationWarning`s; instead, use its replacement, `importlib`.

Differential Revision: https://phabricator.services.mozilla.com/D92632
This commit is contained in:
Ricky Stewart 2020-10-06 16:38:29 +00:00
Родитель e39bac7f69
Коммит e75cd2004d
1 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -9,7 +9,7 @@
from __future__ import absolute_import, print_function
import argparse
import imp
import importlib.util
import os
import six
import sys
@ -57,9 +57,9 @@ def main(argv):
# Since we're invoking the script in a roundabout way, we provide this
# bit of convenience.
sys.path.append(os.path.dirname(script))
with open(script, 'r') as fh:
module = imp.load_module('script', fh, script,
('.py', 'r', imp.PY_SOURCE))
spec = importlib.util.spec_from_file_location('script', script)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
method = args.method_name
if not hasattr(module, method):
print('Error: script "{0}" is missing a {1} method'.format(script, method),