-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
tempname
creates file on Windows but not on *NIX
#9053
Comments
Pretty sure the discrepancy is in
|
mktemp
creates file on Windows but not on *NIXtempname
creates file on Windows but not on *NIX
@tkelman: Thanks, spotted it as I was changing it. =) |
I would probably vote for redefining
The only problem being that it renders It should also be noted that the documentation currently is at least misleading for Windows. |
I like how http://man7.org/linux/man-pages/man3/tempnam.3.html says
That might be a vote for deprecating |
+1 for deprecation unless there's a good use case for not using If |
Opinions, @johnmyleswhite and/or @vtjnash? According to blame it looks like you did most of the writing and rewriting of these functions. |
I think I will side with the deprecation camp. Even if we agree on |
the windows API (like the linux API) is entirely in userspace. it's fine to emulate the whole thing. the windows api creates (and closes) the file to help with the race condition issue mentioned above (and because it uses sequential search for a filename, rather than whatever it is that <insert name of your favorite *nix> does) while tempnam is not recommended, there are applications that require you to pass a filename, rather than a file handle, in which case it is essential. |
@vtjnash: I can certainly see those use-cases. If so, would you consider this solution for *NIX to be satisfactory? Also, would you agree that |
@vtjnash Yet Python has deprecated If the function is really needed we should add the same warning in the docs. @ninjin The name of the function comes from the Unix system call, I agree it's not great. |
@nalimilan we don't differentiate between mktemp and mkstemp, so we don't suffer from the same issue as python's mktemp |
@vtjnash What do you mean? |
I think the following questions should summarise the discussion so far:
I would answer as follows:
|
If |
It would not return the handle, but rather close it. The primary usage of this would be along the lines of what @vtjnash mentioned, when some third-party code out of your control requires a file path. |
So it would return a path to an existing file? That would be confusing, as most likely third-party code which does not accept a handle won't expect the file to exist either (which means you'll have to remove the file manually). |
Related to this issue, #8942 causes the pkg test to fail, but only on Windows, because |
Discussion in JuliaLang#9053.
This issue (and my ignorance thereof) had DataFrames.jl tests failing on Windows, FWIF. |
Ah, is that what that was? Yeah at the very least we need better docs here, if not some way of making these platform differences less likely to cause issues. In response to @ninjin's 4 items above, I'd say
|
Let's add a big warning to the docs for |
Uh, we already have a |
Yeah, not having |
Conclusion from triage: deprecate this to |
Yikes, that seems pretty nasty to use for a very common pattern. I understand that the UNIX and Windows behaviors here are annoyingly different, but shouldn't we have a portable convenient function for getting a temporary filename without doing |
It's racy and not recommended even by posix to ask for a temporary filename without also creating the file, is it really a workflow we need to support with a named exported function? |
My point is that we should have a non-racy, correct way of doing this that is standard. If that involves creating the file in the process, then that's the API we should expose. Is the decision here to tell people to replace this with |
Exactly, this is what |
As noted by @tkelman.
tempname
on Windows does not mean the same thing that it means on *NIX. For *NIX, the relevant docs state that; "The tmpnam() and tempnam() functions return a pointer to a file name on success, and a null pointer on error", while on Windows; "Creates a name for a temporary file. If a unique file name is generated, an empty file is created and the handle to it is released; otherwise, only a file name is generated". Should we accept this discrepancy as a part of our API?The text was updated successfully, but these errors were encountered: