Skip to content

gh-79459 tempfile: Raise a ValueError if the prefix or suffix contains a directory component. - #150477

Merged
vstinner merged 6 commits into
python:mainfrom
mbyrnepr2:gh-79459_tempfile
Oct 5, 2026
Merged

vstinner merged 6 commits into
python:mainfrom
mbyrnepr2:gh-79459_tempfile

Conversation

@mbyrnepr2

Copy link
Copy Markdown
Contributor

tempfile: Raise a ValueError if the prefix or suffix contains a directory component.

gh-79459

@mbyrnepr2 mbyrnepr2 changed the title tempfile: Raise a ValueError if the prefix or suffix contains a directory component. gh-79459 tempfile: Raise a ValueError if the prefix or suffix contains a directory component. May 26, 2026
Comment thread Lib/test/test_tempfile.py Outdated
Comment thread Lib/test/test_tempfile.py Outdated
Comment thread Lib/test/test_tempfile.py Outdated
Comment thread Lib/tempfile.py Outdated
Comment thread Lib/test/test_tempfile.py
Comment thread Lib/test/test_tempfile.py Outdated
@mbyrnepr2

Copy link
Copy Markdown
Contributor Author

Thanks for the first round of reviews Victor! I won't presume to resolve any of the conversations without your approval.

I deliberately didn't touch documentation for now because the contents would depend on knowing the version of Python this change would appear in.
Is 3.16 the earliest realistic target? It's also conceivable that the changes could break existing code for some users so perhaps a longer timeframe is preferable?

Comment thread Lib/test/test_tempfile.py Outdated
Comment thread Lib/test/test_tempfile.py
@vstinner

Copy link
Copy Markdown
Member

@mbyrnepr2: Your PR is still a draft. Please mark it as ready if you consider that it's ready for review.

@mbyrnepr2
mbyrnepr2 marked this pull request as ready for review May 28, 2026 16:37
@github-actions

Copy link
Copy Markdown

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

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Aug 30, 2026
@mbyrnepr2

Copy link
Copy Markdown
Contributor Author

Customary ping 😁. I don't like doing it so as not to be pushy but I just read a post on Discourse that mentioned this was the thing to do.

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Oct 5, 2026

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think that we usually quote parameter names in error messages.

Comment thread Lib/tempfile.py Outdated
Comment thread Lib/tempfile.py Outdated

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks for the updates. The test case now covers all cases, good.

But can you please add a Changelog (NEWS) entry? It's a significant change to reject values which were previously accepted.

Also, please fix the merge conflict (merge main into your branch).

mbyrnepr2 and others added 5 commits October 5, 2026 16:05
Raise a ``ValueError`` if the ``prefix`` or ``suffix`` contains a
directory component.

pythongh-79459
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
remove quotation marks from the error message.
@vstinner
vstinner enabled auto-merge (squash) October 5, 2026 14:26
@vstinner

vstinner commented Oct 5, 2026

Copy link
Copy Markdown
Member

Since it's a backward incompatible change, it should not be backported to Python 3.14 and 3.15.

@vstinner
vstinner merged commit 802f145 into python:main Oct 5, 2026
52 checks passed
@vstinner

vstinner commented Oct 5, 2026

Copy link
Copy Markdown
Member

Merged. Thanks for your fix!

@mbyrnepr2

Copy link
Copy Markdown
Contributor Author

Thank you @vstinner for all your help. It was a pleasure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants