mirror of https://github.com/python/cpython
Make readfile read the file in one fell swoop.
This commit is contained in:
parent
9a1581ceca
commit
5c124871b6
|
@ -4,6 +4,7 @@
|
|||
|
||||
import rand
|
||||
import posix
|
||||
import stat
|
||||
import path
|
||||
|
||||
|
||||
|
@ -40,14 +41,7 @@ def getstatusoutput(cmd):
|
|||
# Return a string containing a file's contents.
|
||||
#
|
||||
def readfile(fn):
|
||||
fp = open(fn, 'r')
|
||||
a = ''
|
||||
n = 8096
|
||||
while 1:
|
||||
b = fp.read(n)
|
||||
if not b: break
|
||||
a = a + b
|
||||
return a
|
||||
return open(fn, 'r').read(posix.stat(fn)[stat.ST_SIZE])
|
||||
|
||||
|
||||
# Make command argument from directory and pathname (prefix space, add quotes).
|
||||
|
|
Loading…
Reference in New Issue