Skip to content

Commit 1a82b09

Browse files
Apply suggestions from code review
Co-authored-by: Brett Cannon <[email protected]>
1 parent 55adff5 commit 1a82b09

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

Doc/library/tempfile.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ The module defines the following user-callable items:
143143
Added *delete_on_close* parameter.
144144

145145
.. versionchanged:: 3.13
146-
Returns a :term:`path-like object`.
146+
Added support for the :term:`path-like object` protocol.
147147

148148

149149
.. class:: SpooledTemporaryFile(max_size=0, mode='w+b', buffering=-1, encoding=None, newline=None, suffix=None, prefix=None, dir=None, *, errors=None)
@@ -221,7 +221,7 @@ The module defines the following user-callable items:
221221
Added the *delete* parameter.
222222

223223
.. versionchanged:: 3.13
224-
Returns a :term:`path-like object`.
224+
Added support for the :term:`path-like object` protocol.
225225

226226

227227
.. function:: mkstemp(suffix=None, prefix=None, dir=None, text=False)

Lib/tempfile.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,7 @@ def func_wrapper(*args, **kwargs):
506506
return a
507507

508508
def __fspath__(self):
509-
"""
510-
Return the filesystem path of this temporary file.
511-
"""
509+
"""Return the filesystem path of the temporary file."""
512510
return self.name
513511

514512
# The underlying __enter__ method returns the wrong object
@@ -945,9 +943,7 @@ def __repr__(self):
945943
return "<{} {!r}>".format(self.__class__.__name__, self.name)
946944

947945
def __fspath__(self):
948-
"""
949-
Return the filesystem path of this temporary directory.
950-
"""
946+
"""Return the filesystem path of the temporary directory."""
951947
return self.name
952948

953949
def __enter__(self):

Lib/test/test_tempfile.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -937,9 +937,7 @@ def do_create(self, dir=None, pre="", suf="", delete=True):
937937

938938
def test_pathlike(self):
939939
tmp = self.do_create()
940-
self.assertTrue(isinstance(tmp, os.PathLike))
941-
cls = type(tmp)
942-
self.assertTrue(issubclass(cls, os.PathLike))
940+
self.assertIsInstance(tmp, os.PathLike)
943941

944942
def test_basic(self):
945943
# NamedTemporaryFile can create files
@@ -1592,9 +1590,7 @@ def do_create(self, dir=None, pre="", suf="", recurse=1, dirs=1, files=1,
15921590

15931591
def test_pathlike(self):
15941592
tmp = self.do_create()
1595-
self.assertTrue(isinstance(tmp, os.PathLike))
1596-
cls = type(tmp)
1597-
self.assertTrue(issubclass(cls, os.PathLike))
1593+
self.assertIsInstance(tmp, os.PathLike)
15981594

15991595
def do_create2(self, path, recurse=1, dirs=1, files=1):
16001596
# Create subdirectories and some files

0 commit comments

Comments
 (0)