Issue 35570: 2to3 creates code using deprecated imp module (original) (raw)

Issue35570

Created on 2018-12-23 12:58 by hanno, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg332390 - (view) Author: Hanno Boeck (hanno) * Date: 2018-12-23 12:58
2to3 (in python 3.6.6) will rewrite the reload function to use the imp module. However according to [1] "Deprecated since version 3.4: The imp package is pending deprecation in favor of importlib." Also running the code with warnings enabled will show a deprecation warning. Example, take this minimal script: #!/usr/bin/python import sys reload(sys) Running to 2to3 ends up with: #!/usr/bin/python import sys import imp imp.reload(sys) $ PYTHONWARNINGS=d python3 foo.py test.py:3: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses import imp [1] https://docs.python.org/3/library/imp.html
msg332395 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-12-23 20:49
Seems this came up when the original version of fixer was added as noted in https://bugs.python.org/issue11797#msg206884 . Looking further this seems to be similar to https://bugs.python.org/issue21446 where it was fixed in 3.7 and master to use importlib.reload . Since 3.6 is having it's last bug fix release I am not sure of the backport. Adding benjamin.peterson to the issue .
msg332692 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-12-29 02:54
It was decided in #21446 to only backport the change, labelled an enhancement, to 3.7 and it is now too late to challenge that decision as 3.6 only gets security fixes.
History
Date User Action Args
2022-04-11 14:59:09 admin set github: 79751
2018-12-29 02:54:45 terry.reedy set status: open -> closedsuperseder: Update reload fixer to use importlib instead of impnosy: + terry.reedymessages: + resolution: duplicatestage: resolved
2018-12-23 20:49:03 xtreak set nosy: + benjamin.peterson, xtreakmessages: +
2018-12-23 12:58:37 hanno create