[Python-bugs-list] [ python-Bugs-571568 ] binary file read/write inconsistency

noreply@sourceforge.net noreply@sourceforge.net
Thu, 20 Jun 2002 02:56:39 -0700


Bugs item #571568, was opened at 2002-06-20 12:56
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=571568&group_id=5470

Category: Windows
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Anatoly Artamonov (arthem)
Assigned to: Tim Peters (tim_one)
Summary: binary file read/write inconsistency

Initial Comment:
I'm using py 2.1.3 for windows
here's a sample code that works fine in Unix and somekind 
weird in Win32:
###############################
import os.path

pth = "22"
f = open(pth,'w')
for k in range(256):  
    f.write(chr(k))
f.close()

f = open(pth)
dat = f.read()
f.close()
print len(dat), 'vs' , os.path.getsize(pth)
print "last read symbol is: 0x%x" % ord(dat[-1])
#################################

Windows version writes 0x0D 0x0A instead of 0x0A so file 
length is 257 bytes instead of 256 as one might expect
and reading just ends at 0x19 (probably end of file 
symbol). 


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=571568&group_id=5470