[Python-Dev] open('/dev/null').read() -> MemoryError
Armin Rigo
arigo at tunes.org
Tue Sep 28 11:37:58 CEST 2004
Hi Bob,
On Mon, Sep 27, 2004 at 04:21:03PM -0400, Bob Ippolito wrote:
> file(path).read() is never really a good idea in the general case -
> especially for a device node.
> In other words, it sounds like the test should be fixed, not the
> implementation.
Sounds good. Does anyone object to the following patch?
Index: test_os.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_os.py,v
retrieving revision 1.27
diff -c -r1.27 test_os.py
*** test_os.py 29 Aug 2004 18:47:31 -0000 1.27
--- test_os.py 28 Sep 2004 09:42:26 -0000
***************
*** 340,346 ****
f.write('hello')
f.close()
f = file(os.devnull, 'r')
! self.assertEqual(f.read(), '')
f.close()
class URandomTests (unittest.TestCase):
--- 340,351 ----
f.write('hello')
f.close()
f = file(os.devnull, 'r')
! self.assertEqual(f.read(1), '')
! self.assertEqual(f.read(10), '')
! self.assertEqual(f.read(100), '')
! self.assertEqual(f.read(1000), '')
! self.assertEqual(f.read(10000), '')
! self.assertEqual(f.read(100000), '')
f.close()
class URandomTests (unittest.TestCase):
-+- Armin
More information about the Python-Dev
mailing list