Skip to content

Commit

Permalink
[Resolves #582] update imp to importlib (#1092)
Browse files Browse the repository at this point in the history
The imp.py library has been deprecated since ver 3.4 in favor of
importlib[1]. This updates to using importlib.

[1] https://docs.python.org/3/library/imp.html
  • Loading branch information
zaro0508 committed Sep 15, 2021
1 parent 381d284 commit 400b488
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions integration-tests/steps/templates.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from behave import *
import os
import imp
import yaml

from botocore.exceptions import ClientError
from importlib.machinery import SourceFileLoader
from sceptre.plan.plan import SceptrePlan
from sceptre.context import SceptreContext
from sceptre.cli.helpers import CfnYamlLoader
Expand Down Expand Up @@ -112,7 +112,7 @@ def step_impl(context, filename):
context.sceptre_dir, "templates", filename
)

module = imp.load_source("template", filepath)
module = SourceFileLoader("template", filepath).load_module()
body = module.sceptre_handler({})
for template in context.output.values():
assert body == template
4 changes: 2 additions & 2 deletions sceptre/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
and implements methods for uploading it to S3.
"""

import imp
import logging
import os
import sys
import threading
import traceback

import botocore
from importlib.machinery import SourceFileLoader
from jinja2 import Environment
from jinja2 import FileSystemLoader
from jinja2 import StrictUndefined
Expand Down Expand Up @@ -174,7 +174,7 @@ def _call_sceptre_handler(self):
if not os.path.isfile(self.path):
raise IOError("No such file or directory: '%s'", self.path)

module = imp.load_source(self.name, self.path)
module = SourceFileLoader(self.name, self.path).load_module()

try:
body = module.sceptre_handler(self.sceptre_user_data)
Expand Down

0 comments on commit 400b488

Please sign in to comment.