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.

classification
Title: file.read() doesn't read the whole file
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Ultrasick, vstinner
Priority: normal Keywords:

Created on 2009-03-24 17:24 by Ultrasick, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test.bmp Ultrasick, 2009-03-24 17:24
Messages (4)
msg84098 - (view) Author: (Ultrasick) Date: 2009-03-24 17:24
--------------------------------------------------------
# open the file
file = open('F:/test.bmp', 'r')

# read the content
content = file.read()

# close the file
file.close()

print "len(content): " + str(len(content))
--------------------------------------------------------
Returns

len(content): 1522

on my computer. But it should be something like

len(content): 1248858
msg84099 - (view) Author: (Ultrasick) Date: 2009-03-24 17:25
tested with python 2.6.1, Windows 2k
msg84100 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-03-24 17:26
Retry in binary mode: open('F:/test.bmp', 'rb'). It's not a bug :-)
http://docs.python.org/library/functions.html#open
msg84101 - (view) Author: (Ultrasick) Date: 2009-03-24 17:35
ok thanks, sorry
History
Date User Action Args
2022-04-11 14:56:46adminsetgithub: 49804
2009-03-24 17:35:55Ultrasicksetmessages: + msg84101
2009-03-24 17:27:15vstinnersetstatus: open -> closed
resolution: not a bug
2009-03-24 17:26:57vstinnersetnosy: + vstinner
messages: + msg84100
2009-03-24 17:25:55Ultrasicksetmessages: + msg84099
2009-03-24 17:24:55Ultrasickcreate