This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ivank
Recipients ivank, neologix, pitrou, vstinner
Date 2014-06-29.17:05:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1404061535.41.0.42371906506.issue21090@psf.upfronthosting.co.za>
In-reply-to
Content
I managed to reproduce this again, this time by corrupting data on a btrfs filesystem.

$ cat read_error_file.py    
import os

fname = "/usr/bin/Xorg"
size = os.stat(fname).st_size
print fname, "stat size:", size

f = open(fname, "rb")
print "len(f.read()): ", len(f.read())
f.close()

f = open(fname, "rb")
for i in xrange(size):
        try:
                f.read(1)
        except IOError:
                print "IOError at byte %d" % i
                break
f.close()

$ python read_error_file.py 
/usr/bin/Xorg stat size: 2331776
len(f.read()):  716800
IOError at byte 716800

Note how the first test does not throw an IOError, but the second one does.

The strace for the first test is:

open("/usr/bin/Xorg", O_RDONLY)         = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=2331776, ...}) = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=2331776, ...}) = 0
lseek(3, 0, SEEK_CUR)                   = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=2331776, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1334bd6000
lseek(3, 0, SEEK_CUR)                   = 0
mmap(NULL, 2334720, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1332ea6000
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\265M\4\0\0\0\0\0"..., 2330624) = 716800
read(3, 0x7f1332f55034, 1613824)        = -1 EIO (Input/output error)
mremap(0x7f1332ea6000, 2334720, 720896, MREMAP_MAYMOVE) = 0x7f1332ea6000
munmap(0x7f1332ea6000, 720896)          = 0
write(1, "len(f.read()):  716800\n", 23len(f.read()):  716800
) = 23

Note the "-1 EIO (Input/output error)" that gets ignored somewhere.
History
Date User Action Args
2014-06-29 17:05:35ivanksetrecipients: + ivank, pitrou, vstinner, neologix
2014-06-29 17:05:35ivanksetmessageid: <1404061535.41.0.42371906506.issue21090@psf.upfronthosting.co.za>
2014-06-29 17:05:35ivanklinkissue21090 messages
2014-06-29 17:05:34ivankcreate