Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 764d612

Browse files
committed
Remove redundant context manager.
1 parent 43e4ea1 commit 764d612

1 file changed

Lines changed: 1 addition & 15 deletions

File tree

Lib/importlib/_bootstrap.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,6 @@ def _path_absolute(path):
8080
return _path_join(_os.getcwd(), path)
8181

8282

83-
class _closing:
84-
85-
"""Simple replacement for contextlib.closing."""
86-
87-
def __init__(self, obj):
88-
self.obj = obj
89-
90-
def __enter__(self):
91-
return self.obj
92-
93-
def __exit__(self, *args):
94-
self.obj.close()
95-
96-
9783
def _wrap(new, old):
9884
"""Simple substitute for functools.wraps."""
9985
for replace in ['__module__', '__name__', '__doc__']:
@@ -468,7 +454,7 @@ def get_filename(self, fullname):
468454

469455
def get_data(self, path):
470456
"""Return the data from path as raw bytes."""
471-
with _closing(_io.FileIO(path, 'r')) as file:
457+
with _io.FileIO(path, 'r') as file:
472458
return file.read()
473459

474460

0 commit comments

Comments
 (0)