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:
Ned Batchelder
2020-05-01 10:29:57 -04:00
committed by GitHub
3 changed files with 7 additions and 11 deletions

View File

@@ -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:

View File

@@ -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,

View File

@@ -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: