Show More
@@ -415,10 +415,16 b' class bufferedinputpipe(object):' | |||
|
415 | 415 | return data |
|
416 | 416 | |
|
417 | 417 | |
|
418 | def mmapread(fp): | |
|
418 | def mmapread(fp, size=None): | |
|
419 | if size == 0: | |
|
420 | # size of 0 to mmap.mmap() means "all data" | |
|
421 | # rather than "zero bytes", so special case that. | |
|
422 | return b'' | |
|
423 | elif size is None: | |
|
424 | size = 0 | |
|
419 | 425 | try: |
|
420 | 426 | fd = getattr(fp, 'fileno', lambda: fp)() |
|
421 |
return mmap.mmap(fd, |
|
|
427 | return mmap.mmap(fd, size, access=mmap.ACCESS_READ) | |
|
422 | 428 | except ValueError: |
|
423 | 429 | # Empty files cannot be mmapped, but mmapread should still work. Check |
|
424 | 430 | # if the file is empty, and if so, return an empty buffer. |
General Comments 0
You need to be logged in to leave comments.
Login now