-
-
Notifications
You must be signed in to change notification settings - Fork 30.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cpython/Lib/tempfile.py] mkdtemp
- canonicalise directory name
#114545
Labels
type-feature
A feature request or enhancement
Comments
I encountered this a while back # MacOS
>>> from tempfile import TemporaryDirectory
>>> from pathlib import Path
>>> TemporaryDirectory().name
'/var/folders/kj/5xf97h1x0t741q334hgxxf_r0000gn/T/tmpcqfpeiwq'
>>> Path(TemporaryDirectory().name).resolve()
PosixPath('/private/var/folders/kj/5xf97h1x0t741q334hgxxf_r0000gn/T/tmp0sfpzcnh') Was also brought up in this discussion https://discuss.python.org/t/tempfile-temporarydirectory-name-should-return-pathlib-path-instead-of-str/40900/10 |
Hi, I think this (with additional tests) deserves a PR, and PRs are welcome in Python. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature or enhancement
Proposal:
I just solved an annoying bug where my temporary directory worked on Windows and Linux but not macOS; because
mkdtemp
doesn't canonicalise its output; causing"/private/"
to be prefixed to some of my paths but not the first path out ofwith TemporaryDirectory() as directory
.I found where the one line solution can be applied:
https://github.com/python/cpython/blob/3.12/Lib/tempfile.py#L395
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
This was discussed on the Node.js project nodejs/node#11422
Linked PRs
mkdtemp
- canonicalise directory name #114691The text was updated successfully, but these errors were encountered: