This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brett.cannon
Recipients Arfrever, brett.cannon, larry
Date 2015-03-30.13:33:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1427722401.47.0.0508664395903.issue23810@psf.upfronthosting.co.za>
In-reply-to
Content
Probably need to introduce a new keyword argument just for deprecated imports or some helper function in importlib to get the stack depth right (else there is a risk of breaking the stack depth in any minor release whenever importlib's depth shifts). Something like the following should be enough (obviously done in warnings instead of per-file):

try:
    level = 1
    while True:
        frame = sys._getframe(level)
        print(frame.f_code.co_filename)
        if '_bootstrap' not in frame.f_code.co_filename:
            break
        level += 1
except ValueError:
    pass
print(sys._getframe(2).f_code.co_filename)
warnings.warn("the imp module is deprecated in favour of importlib; "
              "see the module's documentation for alternative uses",
              PendingDeprecationWarning, stacklevel=level+1)

Otherwise the depths should just go back to what they were at.
History
Date User Action Args
2015-03-30 13:33:21brett.cannonsetrecipients: + brett.cannon, larry, Arfrever
2015-03-30 13:33:21brett.cannonsetmessageid: <1427722401.47.0.0508664395903.issue23810@psf.upfronthosting.co.za>
2015-03-30 13:33:21brett.cannonlinkissue23810 messages
2015-03-30 13:33:21brett.cannoncreate