bpo-35803: Document and test dir=PathLike for tempfile#11644
Conversation
0e73855 to
806270f
Compare
There was a problem hiding this comment.
Is there a difference between current code and isinstance(dir, (str, os.PathLike))?
There was a problem hiding this comment.
ever so slightly. The current code is "type is exactly str", my patch is "type is exactly str or it implements PathLike", your suggestion is "str or any subclass of str or implements PathLike"
There was a problem hiding this comment.
Minor nit
| is a :term:`path-like object`. Patch by Anthony Sottile | |
| is a :term:`path-like object`. Patch by Anthony Sottile. |
There was a problem hiding this comment.
Also can state the two functions directly here instead of tempfile functions?
There was a problem hiding this comment.
it's not just two functions, it's every function in the tempfile module
There was a problem hiding this comment.
ah I see what you're saying here.
I only added the versionchanged comment to the two functions following the convention for the versionchanged directly above it. The functions in the tempfile module all mention "The dir, prefix and suffix parameters have the same meaning and defaults as with mkstemp()." and don't document those parameters themselves
806270f to
9a15af2
Compare
ammaraskar
left a comment
There was a problem hiding this comment.
LGTM with suggestions.
Thanks for the patch Anthony. Confirmed that 3.6 seems to be the first version path objects started working. It would be helpful to introduce this test to ensure that it doesn't accidentally break over time.
| self.assertIs( | ||
| type(name), | ||
| str | ||
| if type(dir) is str or isinstance(dir, os.PathLike) else |
There was a problem hiding this comment.
Maybe break this up to it's own line since its getting a bid crowded as a ternary
…ae6Lq.rst Co-Authored-By: Ammar Askar <ammar_askar@hotmail.com>
| @@ -0,0 +1,3 @@ | |||
| Document and test that ``tempfile`` functions may accept a | |||
| :term:`path-like object` for the ``dir`` argument. Patch by Anthony Sottile. | |||
| is a :term:`path-like object`. Patch by Anthony Sottile. | |||
There was a problem hiding this comment.
The suggestion went awry here; this last line needs to go away.
Co-Authored-By: Ammar Askar <ammar_askar@hotmail.com> (cherry picked from commit 370138b) Co-authored-by: Anthony Sottile <asottile@umich.edu>
|
GH-15796 is a backport of this pull request to the 3.8 branch. |
|
Thanks for the patch and reviews! |
|
GH-15797 is a backport of this pull request to the 3.7 branch. |
Co-Authored-By: Ammar Askar <ammar_askar@hotmail.com> (cherry picked from commit 370138b) Co-authored-by: Anthony Sottile <asottile@umich.edu>
Co-Authored-By: Ammar Askar <ammar_askar@hotmail.com>
https://bugs.python.org/issue35803