Browse Source

Use file object's .closed instead of _istream_open

Matthew Wang 11 years ago
parent
commit
e83642c799
1 changed files with 1 additions and 3 deletions
  1. 1
    3
      cdiff.py

+ 1
- 3
cdiff.py View File

234
         self._istream = istream
234
         self._istream = istream
235
         self._translator = translator
235
         self._translator = translator
236
 
236
 
237
-        self._istream_open = True
238
         self._set_non_block(self._translator.stdin)
237
         self._set_non_block(self._translator.stdin)
239
         self._set_non_block(self._translator.stdout)
238
         self._set_non_block(self._translator.stdout)
240
 
239
 
253
                 break       # EAGAIN
252
                 break       # EAGAIN
254
         else:
253
         else:
255
             self._translator.stdin.close()
254
             self._translator.stdin.close()
256
-            self._istream_open = False
257
 
255
 
258
     def __iter__(self):
256
     def __iter__(self):
259
         while True:
257
         while True:
263
                     return
261
                     return
264
                 yield line
262
                 yield line
265
             except IOError:
263
             except IOError:
266
-                if self._istream_open:
264
+                if not self._translator.stdin.closed:
267
                     self._forward_until_block()
265
                     self._forward_until_block()
268
                 continue    # EAGAIN
266
                 continue    # EAGAIN
269
 
267