Bugs item #1174606, was opened at 2005-04-01 04:48 Message generated for change (Comment added) made by arigo You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1174606&group_id=5470
Category: Python Interpreter Core Group: None Status: Open Resolution: None Priority: 5 Submitted By: Adam Olsen (rhamphoryncus) Assigned to: Nobody/Anonymous (nobody) Summary: Reading /dev/zero causes SystemError Initial Comment: $ python -c 'open("/dev/zero").read()' Traceback (most recent call last): File "<string>", line 1, in ? SystemError: ../Objects/stringobject.c:3316: bad argument to internal function Compare with this two variants: $ python -c 'open("/dev/zero").read(2**31-1)' Traceback (most recent call last): File "<string>", line 1, in ? MemoryError $ python -c 'open("/dev/zero").read(2**31)' Traceback (most recent call last): File "<string>", line 1, in ? OverflowError: long int too large to convert to int The unsized read should produce either MemoryError or OverflowError instead of SystemError. Tested with Python 2.2, 2.3, and 2.4. ---------------------------------------------------------------------- >Comment By: Armin Rigo (arigo) Date: 2005-04-01 09:58 Message: Logged In: YES user_id=4771 I think that file.read() with no argument needs to be more conservative. Currently it asks and trusts the stat() to get the file size, but this can lead to just plain wrong results on special devices. (I had the problem that open('/dev/null').read() would give a MemoryError!) We can argue whether plain read() on special devices is a good idea or not, but I guess that not blindly trusting stat() if it returns huge values could be a good idea. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1174606&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com