Skip to content

Commit 412032b

Browse files
Use a named constant.
1 parent efcb8c5 commit 412032b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Lib/plistlib.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@
7373
PlistFormat = enum.Enum('PlistFormat', 'FMT_XML FMT_BINARY', module=__name__)
7474
globals().update(PlistFormat.__members__)
7575

76+
# Data larger than this will be read in chunks, to prevent extreme
77+
# overallocation.
78+
_SAFE_BUF_SIZE = 1 << 20
7679

7780
class UID:
7881
def __init__(self, data):
@@ -509,7 +512,7 @@ def _get_size(self, tokenL):
509512
return tokenL
510513

511514
def _read(self, size):
512-
cursize = min(size, 1 << 20)
515+
cursize = min(size, _SAFE_BUF_SIZE)
513516
data = self._fp.read(cursize)
514517
while True:
515518
if len(data) != cursize:

0 commit comments

Comments
 (0)