Brett Cannon added the comment:
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.
----------
nosy: +larry
priority: normal -> release blocker
stage: -> test needed
type: -> behavior
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue23810>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com