Merge pull request #23861 from regisb/regisb/quiet-imp-deprecation-warnings
CRI-196 Quiet deprecation warnings from imp and courseware modules
This commit is contained in:
@@ -40,7 +40,7 @@ When refering to XBlocks, we use the entry-point name. For example,
|
||||
|
||||
# pylint: disable=unused-import, useless-suppression, wrong-import-order, wrong-import-position
|
||||
|
||||
import imp
|
||||
import importlib.util
|
||||
import os
|
||||
import sys
|
||||
from datetime import timedelta
|
||||
@@ -1623,10 +1623,8 @@ OPTIONAL_APPS = (
|
||||
for app_name, insert_before in OPTIONAL_APPS:
|
||||
# First attempt to only find the module rather than actually importing it,
|
||||
# to avoid circular references - only try to import if it can't be found
|
||||
# by find_module, which doesn't work with import hooks
|
||||
try:
|
||||
imp.find_module(app_name)
|
||||
except ImportError:
|
||||
# by find_spec, which doesn't work with import hooks
|
||||
if importlib.util.find_spec(app_name) is None:
|
||||
try:
|
||||
__import__(app_name)
|
||||
except ImportError:
|
||||
|
||||
@@ -11,7 +11,7 @@ from django.contrib.auth.models import User
|
||||
from django.http import Http404
|
||||
|
||||
from bulk_email.models import Optout
|
||||
from courseware.courses import get_course_by_id
|
||||
from lms.djangoapps.courseware.courses import get_course_by_id
|
||||
from edxmako.shortcuts import render_to_response
|
||||
from lms.djangoapps.discussion.notification_prefs.views import (
|
||||
UsernameCipher,
|
||||
|
||||
@@ -29,7 +29,7 @@ Longer TODO:
|
||||
# pylint: disable=invalid-name, wrong-import-position
|
||||
|
||||
|
||||
import imp
|
||||
import importlib.util
|
||||
import sys
|
||||
import os
|
||||
|
||||
@@ -3181,10 +3181,8 @@ OPTIONAL_APPS = [
|
||||
for app_name, insert_before in OPTIONAL_APPS:
|
||||
# First attempt to only find the module rather than actually importing it,
|
||||
# to avoid circular references - only try to import if it can't be found
|
||||
# by find_module, which doesn't work with import hooks
|
||||
try:
|
||||
imp.find_module(app_name)
|
||||
except ImportError:
|
||||
# by find_spec, which doesn't work with import hooks
|
||||
if importlib.util.find_spec(app_name) is None:
|
||||
try:
|
||||
__import__(app_name)
|
||||
except ImportError:
|
||||
|
||||
Reference in New Issue
Block a user