from __future__ import absolute_import

import warnings

if __name__ == 'courseware':
    warnings.warn("Importing 'lms.djangoapps.courseware' as 'courseware' is no longer supported", DeprecationWarning)

from __future__ import absolute_import

import inspect
import warnings

if __name__ == 'courseware':
    # pylint: disable=unicode-format-string
    # Show the call stack that imported us wrong.
    stack = "\n".join("%30s : %s:%d" % (t[3], t[1], t[2]) for t in inspect.stack()[:0:-1])
    msg = "Importing 'lms.djangoapps.courseware' as 'courseware' is no longer supported:\n" + stack
    warnings.warn(msg, DeprecationWarning)

Add more diagnostics to the courseware import warning
Add more diagnostics to the courseware import warning

  from __future__ import absolute_import
  
+ import inspect
  import warnings
  
  if __name__ == 'courseware':
+     # pylint: disable=unicode-format-string
+     # Show the call stack that imported us wrong.
+     stack = "\n".join("%30s : %s:%d" % (t[3], t[1], t[2]) for t in inspect.stack()[:0:-1])
-     warnings.warn("Importing 'lms.djangoapps.courseware' as 'courseware' is no longer supported", DeprecationWarning)
+     msg = "Importing 'lms.djangoapps.courseware' as 'courseware' is no longer supported:\n" + stack
+     warnings.warn(msg, DeprecationWarning)
  
Add more diagnostics to the courseware import warning
## Code Before:
from __future__ import absolute_import

import warnings

if __name__ == 'courseware':
    warnings.warn("Importing 'lms.djangoapps.courseware' as 'courseware' is no longer supported", DeprecationWarning)

## Instruction:
Add more diagnostics to the courseware import warning
## Code After:
from __future__ import absolute_import

import inspect
import warnings

if __name__ == 'courseware':
    # pylint: disable=unicode-format-string
    # Show the call stack that imported us wrong.
    stack = "\n".join("%30s : %s:%d" % (t[3], t[1], t[2]) for t in inspect.stack()[:0:-1])
    msg = "Importing 'lms.djangoapps.courseware' as 'courseware' is no longer supported:\n" + stack
    warnings.warn(msg, DeprecationWarning)
