[Python-checkins] r84469 - python/branches/py3k/Lib/importlib/_bootstrap.py

florent.xicluna python-checkins at python.org
Fri Sep 3 21:55:26 CEST 2010


Author: florent.xicluna
Date: Fri Sep  3 21:55:26 2010
New Revision: 84469

Log:
Remove redundant context manager.

Modified:
   python/branches/py3k/Lib/importlib/_bootstrap.py

Modified: python/branches/py3k/Lib/importlib/_bootstrap.py
==============================================================================
--- python/branches/py3k/Lib/importlib/_bootstrap.py	(original)
+++ python/branches/py3k/Lib/importlib/_bootstrap.py	Fri Sep  3 21:55:26 2010
@@ -80,20 +80,6 @@
             return _path_join(_os.getcwd(), path)
 
 
-class _closing:
-
-    """Simple replacement for contextlib.closing."""
-
-    def __init__(self, obj):
-        self.obj = obj
-
-    def __enter__(self):
-        return self.obj
-
-    def __exit__(self, *args):
-        self.obj.close()
-
-
 def _wrap(new, old):
     """Simple substitute for functools.wraps."""
     for replace in ['__module__', '__name__', '__doc__']:
@@ -468,7 +454,7 @@
 
     def get_data(self, path):
         """Return the data from path as raw bytes."""
-        with _closing(_io.FileIO(path, 'r')) as file:
+        with _io.FileIO(path, 'r') as file:
             return file.read()
 
 


More information about the Python-checkins mailing list