Skip to content

Commit a03e185

Browse files
committed
shutil: Implement copyfileobj().
1 parent c89a9fd commit a03e185

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

shutil/shutil.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,15 @@ def rmtree(top):
77
for f in files:
88
os.unlink(path + "/" + f)
99
os.rmdir(path)
10+
11+
def copyfileobj(src, dest, length=512):
12+
buf = bytearray(length)
13+
while True:
14+
sz = src.readinto(buf)
15+
if not sz:
16+
break
17+
if sz == length:
18+
dest.write(buf)
19+
else:
20+
b = memoryview(buf)[:sz]
21+
dest.write(b)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy