Issue 1450456: windows python truncates files when reading them (original) (raw)
Issue1450456
Created on 2006-03-15 15:17 by object, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg27785 - (view) | Author: tom berger (object) | Date: 2006-03-15 15:17 |
when using python for windows, opening a file and calling read() on the file object returns only some of the file (about 1K). i am expecting read to return the entire contents of the file (and this is what i get when i run the same code on cygwin and linux). to reproduce: prepare a sufficiently large file myfile.xxx (say > 100K) source = open('myfile.xxx', 'r') dest = open('copy_myfile.xxx', 'w') dest.write(source.read()) source.close() dest.close() myfile.xxx and copy_myfile.xxx should be identical, and they are if you run this on most python distributions. when running the version installed from the .msi installer on python.org the copy is truncated (as part of reading, i'm pretty sure). | ||
msg27786 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2006-03-15 15:22 |
Logged In: YES user_id=849994 I'm guessing here, but the only conclusion is that you are reading a binary file. Since Windows makes a difference between text and binary files, you must read the file with mode 'rb', or Windows will stop at the first chr(26) == Ctrl+Z == EOF. | ||
msg27787 - (view) | Author: tom berger (object) | Date: 2006-03-15 15:36 |
Logged In: YES user_id=110577 yes, of course. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:15 | admin | set | github: 43037 |
2006-03-15 15:17:23 | object | create |