Skip to content

gh-152586: Make tempfile.TemporaryFileWrapper public#152646

Open
Aniketsy wants to merge 16 commits into
python:mainfrom
Aniketsy:fix-152586
Open

gh-152586: Make tempfile.TemporaryFileWrapper public#152646
Aniketsy wants to merge 16 commits into
python:mainfrom
Aniketsy:fix-152586

Conversation

@Aniketsy

@Aniketsy Aniketsy commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

@read-the-docs-community

read-the-docs-community Bot commented Jun 30, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33407429 | 📁 Comparing 375a717 against main (5717518)

  🔍 Preview build  

28 files changed · ± 28 modified

± Modified

Comment thread Doc/library/tempfile.rst Outdated
Comment thread Lib/test/test_tempfile.py Outdated
self.assertIn("TemporaryFileWrapper", tempfile.__all__)

def test_is_return_type_of_named_temporary_file(self):
with tempfile.NamedTemporaryFile() as f:

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 propose to move this check to any existing test above.

Comment thread Lib/tempfile.py Outdated
for line in self.file:
yield line

_TemporaryFileWrapper = TemporaryFileWrapper

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.

Please, add a comment: why it is there.
Question: does it make sence to deprecate the older alias at the same time?

@Aniketsy Aniketsy Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Please, add a comment: why it is there.

sure 👍

Question: does it make sence to deprecate the older alias at the same time?

I think we can deprecate in follow up, but if you prefer we should add in this PR, only-- i'm happy to go with

Thanks for the review!

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 would deprecate it right away :)

Co-authored-by: sobolevn <mail@sobolevn.me>

@ByteFlowing1337 ByteFlowing1337 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think these changes need a news entry. Could you please add one?

Comment thread Lib/tempfile.py
raw = getattr(raw, 'raw', raw)
raw.name = name
return _TemporaryFileWrapper(file, name, delete, delete_on_close)
return TemporaryFileWrapper(file, name, delete, delete_on_close)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

test_unexpected_error is failing because you did not change mock.patch('tempfile._TemporaryFileWrapper') to mock.patch('tempfile.TemporaryFileWrapper') in that function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks for pointing out

@sobolevn sobolevn 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.

Please, also add a new deprecation entry to Doc/whatsnew/3.16.rst and add tempfile._TemporaryFileWrapper to be removed to Doc/deprecations/pending-removal-in-3.21.rst

Comment thread Doc/library/tempfile.rst
Comment thread Lib/tempfile.py Outdated
Comment thread Lib/tempfile.py Outdated
Comment thread Misc/NEWS.d/next/Library/2026-07-01-22-59-25.gh-issue-152586.WuEae6.rst Outdated
Aniketsy and others added 4 commits July 2, 2026 11:55
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: sobolevn <mail@sobolevn.me>
…uEae6.rst

Co-authored-by: sobolevn <mail@sobolevn.me>
@Aniketsy Aniketsy requested a review from AA-Turner as a code owner July 2, 2026 07:24
Comment thread Doc/library/tempfile.rst Outdated
Comment thread Lib/test/test_tempfile.py Outdated
Comment thread Lib/tempfile.py Outdated
@sobolevn

sobolevn commented Jul 2, 2026

Copy link
Copy Markdown
Member

Please, resolve conflicts :)

Aniketsy and others added 4 commits July 2, 2026 13:05
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: sobolevn <mail@sobolevn.me>
Comment thread Doc/whatsnew/3.16.rst
@sobolevn

sobolevn commented Jul 2, 2026

Copy link
Copy Markdown
Member

Let's ask @savannahostrowski as the release manager of 3.16 if this change is ok :)

@sobolevn sobolevn 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.

One last comment from me :)

Comment thread Doc/library/tempfile.rst
Comment thread Doc/library/tempfile.rst Outdated
Co-authored-by: sobolevn <mail@sobolevn.me>
Comment thread Misc/NEWS.d/next/Library/2026-07-01-22-59-25.gh-issue-152586.WuEae6.rst Outdated
…uEae6.rst

Co-authored-by: sobolevn <mail@sobolevn.me>

@sobolevn sobolevn 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.

Great work!

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.

Make tempfile._TemporaryFileWrapper public

3 participants