@@ -416,6 +416,9 @@ def _is_printable(ch):
416416__use_inmemfile__ = True
417417__use_spoolfile__ = False
418418__use_spooldir__ = tempfile.gettempdir()
419+ BYTES_PER_MiB = 1024 * 1024
420+ DEFAULT_SPOOL_MAX = 8 * BYTES_PER_MiB
421+ __use_spooldir__ = DEFAULT_SPOOL_MAX
419422__program_name__ = "Py"+__file_format_default__
420423__use_env_file__ = True
421424__use_ini_file__ = True
@@ -1967,7 +1970,7 @@ def MkTempFile(data=None,
19671970 dir=None,
19681971 suffix="",
19691972 use_spool=__use_spoolfile__,
1970- spool_max=8 * 1024 * 1024 ,
1973+ spool_max=__use_spooldir__ ,
19711974 spool_dir=__use_spooldir__):
19721975 """
19731976 Return a file-like handle with consistent behavior on Py2.7 and Py3.x.
@@ -2411,7 +2414,7 @@ class ZlibFile(object):
24112414
24122415 def __init__(self, file_path=None, fileobj=None, mode='rb', level=6, wbits=15,
24132416 encoding=None, errors=None, newline=None,
2414- tolerant_read=False, scan_bytes=(64 << 10), spool_threshold=(8 << 20) ):
2417+ tolerant_read=False, scan_bytes=(64 << 10), spool_threshold=__use_spooldir__ ):
24152418
24162419 if file_path is None and fileobj is None:
24172420 raise ValueError("Either file_path or fileobj must be provided")
@@ -2898,7 +2901,7 @@ class GzipFile(object):
28982901
28992902 def __init__(self, file_path=None, fileobj=None, mode='rb',
29002903 level=6, encoding=None, errors=None, newline=None,
2901- tolerant_read=False, scan_bytes=(64 << 10), spool_threshold=(8 << 20) ):
2904+ tolerant_read=False, scan_bytes=(64 << 10), spool_threshold=__use_spooldir__ ):
29022905
29032906 if file_path is None and fileobj is None:
29042907 raise ValueError("Either file_path or fileobj must be provided")
@@ -3344,7 +3347,7 @@ def __init__(self, file_path=None, fileobj=None, mode='rb',
33443347 level=9, encoding=None, errors=None, newline=None,
33453348 write_header=True,
33463349 tolerant_read=False, scan_bytes=(64 << 10),
3347- spool_threshold=(8 << 20) ):
3350+ spool_threshold=__use_spooldir__ ):
33483351 """
33493352 Custom LZO file (NOT the lzop(1) format).
33503353 - streaming write/read, supports concatenated members
@@ -3819,7 +3822,7 @@ def lzop_compress_bytes(payload, level=9, text=False, **kw):
38193822
38203823
38213824def lzop_decompress_bytes(blob, mode='rb', tolerant_read=False, scan_bytes=(64 << 10),
3822- spool_threshold=(8 << 20) , **kw):
3825+ spool_threshold=__use_spooldir__ , **kw):
38233826 """
38243827 Decompress bytes produced by this custom container.
38253828 - mode='rb' -> returns bytes; mode='rt' -> returns text (set encoding/errors/newline in kw)
@@ -9786,7 +9789,7 @@ def fast_copy(infp, outfp, bufsize=1 << 20):
97869789 outfp.write(data)
97879790
97889791
9789- def copy_file_to_mmap_dest(src_path, outfp, chunk_size=8 << 20 ):
9792+ def copy_file_to_mmap_dest(src_path, outfp, chunk_size=__use_spooldir__ ):
97909793 """
97919794 Copy a disk file into an mmap-backed destination (FileLikeAdapter).
97929795 Falls back to buffered copy if the source cannot be mmapped.
0 commit comments