Skip to content

Commit b48389d

Browse files
authored
bpo-33239: Fix default value of 'buffering' parameter in docs of tempfile.* functions (GH-21763)
`None` doesn't work: ```python >>> import tempfile >>> tempfile.TemporaryFile(buffering=None) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/sergey/tmp/cpython-dev/Lib/tempfile.py", line 607, in TemporaryFile return _io.open(fd, mode, buffering=buffering, TypeError: 'NoneType' object cannot be interpreted as an integer ``` Automerge-Triggered-By: @vsajip
1 parent c753306 commit b48389d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Doc/library/tempfile.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ is recommended to use keyword arguments for clarity.
3131

3232
The module defines the following user-callable items:
3333

34-
.. function:: TemporaryFile(mode='w+b', buffering=None, encoding=None, newline=None, suffix=None, prefix=None, dir=None, *, errors=None)
34+
.. function:: TemporaryFile(mode='w+b', buffering=-1, encoding=None, newline=None, suffix=None, prefix=None, dir=None, *, errors=None)
3535

3636
Return a :term:`file-like object` that can be used as a temporary storage area.
3737
The file is created securely, using the same rules as :func:`mkstemp`. It will be destroyed as soon
@@ -72,7 +72,7 @@ The module defines the following user-callable items:
7272
Added *errors* parameter.
7373

7474

75-
.. function:: NamedTemporaryFile(mode='w+b', buffering=None, encoding=None, newline=None, suffix=None, prefix=None, dir=None, delete=True, *, errors=None)
75+
.. function:: NamedTemporaryFile(mode='w+b', buffering=-1, encoding=None, newline=None, suffix=None, prefix=None, dir=None, delete=True, *, errors=None)
7676

7777
This function operates exactly as :func:`TemporaryFile` does, except that
7878
the file is guaranteed to have a visible name in the file system (on
@@ -93,7 +93,7 @@ The module defines the following user-callable items:
9393
Added *errors* parameter.
9494

9595

96-
.. function:: SpooledTemporaryFile(max_size=0, mode='w+b', buffering=None, encoding=None, newline=None, suffix=None, prefix=None, dir=None, *, errors=None)
96+
.. function:: SpooledTemporaryFile(max_size=0, mode='w+b', buffering=-1, encoding=None, newline=None, suffix=None, prefix=None, dir=None, *, errors=None)
9797

9898
This function operates exactly as :func:`TemporaryFile` does, except that
9999
data is spooled in memory until the file size exceeds *max_size*, or

0 commit comments

Comments
 (0)