Skip to content

Specify tempfile random naming constraints #24785

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

Closed
wants to merge 4 commits into from
Closed

Conversation

alanyee
Copy link
Contributor

@alanyee alanyee commented Mar 8, 2021

Specify which random characters are used during temporary file name creation. Trivial PR, but it may be helpful for developers to know what characters are used during file creation. Source: class _RandomNameSequence

Specify which random characters are used during temporary file name creation
@github-actions
Copy link

github-actions bot commented Apr 8, 2021

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Apr 8, 2021
@alanyee
Copy link
Contributor Author

alanyee commented Apr 8, 2021

I would like this added to the documentation.

@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Apr 9, 2021
@alanyee
Copy link
Contributor Author

alanyee commented Apr 13, 2021

@vstinner may I ask you to review this PR?

@alanyee alanyee requested a review from slateny October 31, 2022 05:12
Copy link
Contributor

@slateny slateny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, though I wonder if this should be spelled out (lowercase alphanumeric characters plus the underscore) instead of using a regex-like expression, since I also couldn't find many examples of a-z being used outside of a regex context. Not too sure which is better though, so I'll let someone else chime in on this

@hauntsaninja
Copy link
Contributor

Thanks for the PR, but this feels like an implementation detail. Would you mind talking more about the use case you have for the exact set of characters used to be a documented guarantee?

@hauntsaninja hauntsaninja added the pending The issue will be closed if no feedback is provided label Dec 22, 2022
@alanyee
Copy link
Contributor Author

alanyee commented Dec 24, 2022

@hauntsaninja I don't exactly want a guarantee or whatnot. At the time of creating this PR, I want to know what the tempfile's randomly generated names would look like, and for my use case at the time, I wanted to generate my own files ensuring I would confuse them for the tempfile's random names. So I decided to look at the source code to see what kind of characters would be used to create the tempfiles, so I decided to document it so that others who had the same inquiry as me would know.

@hauntsaninja
Copy link
Contributor

Okay, thanks, that helps me better understand the use case. I think the right way to disambiguate temporary files from other files is to use the prefix and suffix arguments. I'd much rather encourage users to use those arguments than e.g. rely on the fact that the implementation doesn't currently use a certain character in filenames.

Putting statements in the documentation is essentially a guarantee. I appreciate your intention to save time for others, but curiosity about implementation details is still best served by looking at the implementation (one of my favourite things about Python is that the standard library is quite readable).

@alanyee alanyee deleted the patch-1 branch December 24, 2022 23:49
@AA-Turner AA-Turner removed the pending The issue will be closed if no feedback is provided label Apr 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants