]> granicus.if.org Git - python/commitdiff
simplify and beautify code
authorBenjamin Peterson <benjamin@python.org>
Fri, 6 Mar 2009 23:59:29 +0000 (23:59 +0000)
committerBenjamin Peterson <benjamin@python.org>
Fri, 6 Mar 2009 23:59:29 +0000 (23:59 +0000)
Lib/io.py

index 978e833c253e288facad21546896e13eb62b3766..8a8cf699af63d1c9a8184ad8d5e0da4956cb70d5 100644 (file)
--- a/Lib/io.py
+++ b/Lib/io.py
@@ -58,12 +58,12 @@ __all__ = ["BlockingIOError", "open", "IOBase", "RawIOBase", "FileIO",
 import _io
 import abc
 
-# open() uses st_blksize whenever we can
-DEFAULT_BUFFER_SIZE = _io.DEFAULT_BUFFER_SIZE
-BlockingIOError = _io.BlockingIOError
-UnsupportedOperation = _io.UnsupportedOperation
-open = _io.open
-OpenWrapper = _io.open
+from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation,
+                 open, FileIO, BytesIO, StringIO, BufferedReader,
+                 BufferedWriter, BufferedRWPair, BufferedRandom,
+                 IncrementalNewlineDecoder, TextIOWrapper)
+
+OpenWrapper = _io.open # for compatibility with _pyio
 
 # Declaring ABCs in C is tricky so we do it here.
 # Method descriptions and default implementations are inherited from the C
@@ -80,23 +80,12 @@ class BufferedIOBase(_io._BufferedIOBase, IOBase):
 class TextIOBase(_io._TextIOBase, IOBase):
     pass
 
-FileIO = _io.FileIO
-BytesIO = _io.BytesIO
-StringIO = _io.StringIO
-BufferedReader = _io.BufferedReader
-BufferedWriter = _io.BufferedWriter
-BufferedRWPair = _io.BufferedRWPair
-BufferedRandom = _io.BufferedRandom
-IncrementalNewlineDecoder = _io.IncrementalNewlineDecoder
-TextIOWrapper = _io.TextIOWrapper
-
 RawIOBase.register(FileIO)
 
-BufferedIOBase.register(BytesIO)
-BufferedIOBase.register(BufferedReader)
-BufferedIOBase.register(BufferedWriter)
-BufferedIOBase.register(BufferedRandom)
-BufferedIOBase.register(BufferedRWPair)
+for klass in (BytesIO, BufferedReader, BufferedWriter, BufferedRandom,
+              BufferedRWPair):
+    BufferedIOBase.register(klass)
 
-TextIOBase.register(StringIO)
-TextIOBase.register(TextIOWrapper)
+for klass in (StringIO, TextIOWrapper):
+    TextIOBase.register(klass)
+del klass