Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7a3056fa
Commit
7a3056fa
authored
Jul 23, 2018
by
Berker Peksag
Committed by
GitHub
Jul 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-21446: Update reload fixer to use importlib (GH-8391)
parent
d04f46c5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
10 deletions
+12
-10
Doc/library/2to3.rst
Doc/library/2to3.rst
+1
-1
Lib/lib2to3/fixes/fix_reload.py
Lib/lib2to3/fixes/fix_reload.py
+3
-3
Lib/lib2to3/tests/test_fixers.py
Lib/lib2to3/tests/test_fixers.py
+6
-6
Misc/NEWS.d/next/Library/2018-07-22-09-05-01.bpo-21446.w6g7tn.rst
...S.d/next/Library/2018-07-22-09-05-01.bpo-21446.w6g7tn.rst
+2
-0
No files found.
Doc/library/2to3.rst
View file @
7a3056fa
...
...
@@ -385,7 +385,7 @@ and off individually. They are described here in more detail.
.. 2to3fixer:: reload
Converts :func:`reload` to :func:`imp.reload`.
Converts :func:`reload` to :func:`imp
ortlib
.reload`.
.. 2to3fixer:: renames
...
...
Lib/lib2to3/fixes/fix_reload.py
View file @
7a3056fa
"""Fixer for reload().
reload(s) -> imp.reload(s)"""
reload(s) -> imp
ortlib
.reload(s)"""
# Local imports
from
..
import
fixer_base
...
...
@@ -32,7 +32,7 @@ class FixReload(fixer_base.BaseFix):
if
(
obj
.
type
==
self
.
syms
.
argument
and
obj
.
children
[
0
].
value
==
'**'
):
return
# Make no change.
names
=
(
'imp'
,
'reload'
)
names
=
(
'imp
ortlib
'
,
'reload'
)
new
=
ImportAndCall
(
node
,
results
,
names
)
touch_import
(
None
,
'imp'
,
node
)
touch_import
(
None
,
'imp
ortlib
'
,
node
)
return
new
Lib/lib2to3/tests/test_fixers.py
View file @
7a3056fa
...
...
@@ -290,30 +290,30 @@ class Test_reload(FixerTestCase):
def
test
(
self
):
b
=
"""reload(a)"""
a
=
"""import imp
\
n
imp
.reload(a)"""
a
=
"""import imp
ortlib
\
n
importlib
.reload(a)"""
self
.
check
(
b
,
a
)
def
test_comment
(
self
):
b
=
"""reload( a ) # comment"""
a
=
"""import imp
\
n
imp
.reload( a ) # comment"""
a
=
"""import imp
ortlib
\
n
importlib
.reload( a ) # comment"""
self
.
check
(
b
,
a
)
# PEP 8 comments
b
=
"""reload( a ) # comment"""
a
=
"""import imp
\
n
imp
.reload( a ) # comment"""
a
=
"""import imp
ortlib
\
n
importlib
.reload( a ) # comment"""
self
.
check
(
b
,
a
)
def
test_space
(
self
):
b
=
"""reload( a )"""
a
=
"""import imp
\
n
imp
.reload( a )"""
a
=
"""import imp
ortlib
\
n
importlib
.reload( a )"""
self
.
check
(
b
,
a
)
b
=
"""reload( a)"""
a
=
"""import imp
\
n
imp
.reload( a)"""
a
=
"""import imp
ortlib
\
n
importlib
.reload( a)"""
self
.
check
(
b
,
a
)
b
=
"""reload(a )"""
a
=
"""import imp
\
n
imp
.reload(a )"""
a
=
"""import imp
ortlib
\
n
importlib
.reload(a )"""
self
.
check
(
b
,
a
)
def
test_unchanged
(
self
):
...
...
Misc/NEWS.d/next/Library/2018-07-22-09-05-01.bpo-21446.w6g7tn.rst
0 → 100644
View file @
7a3056fa
The :2to3fixer:`reload` fixer now uses :func:`importlib.reload` instead of
deprecated :func:`imp.reload`.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment