Skip to content

bpo-45593: make SpooledTemporaryFile.truncate return new file size and improve documentation#29197

Open
rooterkyberian wants to merge 5 commits into
python:mainfrom
rooterkyberian:pbo-45593
Open

bpo-45593: make SpooledTemporaryFile.truncate return new file size and improve documentation#29197
rooterkyberian wants to merge 5 commits into
python:mainfrom
rooterkyberian:pbo-45593

Conversation

@rooterkyberian
Copy link
Copy Markdown

@rooterkyberian rooterkyberian commented Oct 23, 2021

https://bugs.python.org/issue45593

Currently SpooledTemporaryFile.truncate doesn't return anything.
This seems to be an old issue common for some SpooledTemporaryFile methods; most recently .seek(...) has been fixed in similar fashion.

https://bugs.python.org/issue45593

@rooterkyberian rooterkyberian changed the title pbo-45593: make SpooledTemporaryFile.truncate return new file size and improve documentation bpo-45593: make SpooledTemporaryFile.truncate return new file size and improve documentation Oct 23, 2021
@github-actions
Copy link
Copy Markdown

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 Nov 23, 2021
Copy link
Copy Markdown
Contributor

@MaxwellDupre MaxwellDupre left a comment

Choose a reason for hiding this comment

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

Ran 99 tests in 1.041s

OK (skipped=2)

== Tests result: SUCCESS ==
Looks ok to me.

@furkanonder
Copy link
Copy Markdown
Contributor

LGTM. @rooterkyberian Can you resolve the conflict?

@rooterkyberian
Copy link
Copy Markdown
Author

@furkanonder done - rebased to current main and resolved conflicts

Comment thread Doc/library/tempfile.rst Outdated
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
Comment thread Doc/library/tempfile.rst
>>> fp.write(b'Hello world!')
# read data from file
>>> fp.seek(0)
0
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.

If we add 0 here, we should add 12 after fp.write(b'Hello world!') too.

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.

And later,

    >>> with tempfile.TemporaryFile() as fp:
    ...     fp.write(b'Hello world!')
    ...     fp.seek(0)
    ...     fp.read()
    b'Hello world!'

This output should be:

12
0
b'Hello world!'

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.

It seems this file is not tested by doctest.

Please leave it. Otherwise, we need to fix all output and remove all comments in sample code.

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Apr 10, 2026
@github-actions
Copy link
Copy Markdown

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 May 11, 2026
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented May 11, 2026

Documentation build overview

📚 cpython-previews | 🛠️ Build #32633580 | 📁 Comparing 1c40e9f against main (f23a183)

  🔍 Preview build  

3 files changed
± c-api/slots.html
± library/tempfile.html
± whatsnew/changelog.html

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

Labels

awaiting core review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants