GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-26175: Implement `io.IOBase` interface for `SpooledTemporaryFile` by pR0Ps · Pull Request #29560 · python/cpython

Conversation

@pR0Ps

@pR0Ps pR0Ps commented Nov 15, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Since the underlying file-like objects (either io.BytesIO, io.StringIO, or a true file object) all implement the io.IOBase interface, the SpooledTemporaryFile should as well.

Additionally, since the underlying file object will either be an instance of an io.BufferedIOBase (for binary mode) or an io.TextIOBase (for text mode), methods for these classes were also implemented.

In every case, the required methods and properties are simply delegated to the underlying file object.

Co-authored-by: Gary Fernie <[email protected]>

This is a rebased and reworked followup of the seemingly-abandoned #3249

https://bugs.python.org/issue26175

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

adriangb and NicolaiSoeborg reacted with hooray emoji adriangb reacted with rocket emoji
All reactions
  • 🎉 2 reactions
  • 🚀 1 reaction
@the-knights-who-say-ni the-knights-who-say-ni added the CLA not signed label Nov 15, 2021
@the-knights-who-say-ni

the-knights-who-say-ni commented Nov 15, 2021

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@pR0Ps

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added the awaiting review label Nov 15, 2021
@ztane

ztane commented Nov 15, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

@pR0Ps I guess you ignored the change requests from the other PR, shouldn't call __del__ like that; see here.

Also IMO you'd want to give the warning regardless of the file having been rolled over to disk or not. BytesIO does not warn in its __del__. Otherwise you'd have warnings that are triggered by the phase of moon.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@the-knights-who-say-ni the-knights-who-say-ni added CLA signed and removed CLA not signed labels Nov 16, 2021
@pR0Ps
pR0Ps force-pushed the bpo-26175_fix-SpooledTemporaryFile-IOBase branch 2 times, most recently from a39b1e8 to 54b6c7b Compare November 16, 2021 01:15
@pR0Ps

pR0Ps commented Nov 16, 2021

Copy link
Copy Markdown
Contributor Author

@ztane Made the requested change to the __del__ method and added a test to ensure that a ResourceWarning is generated in both a rolled and unrolled state.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pR0Ps
pR0Ps force-pushed the bpo-26175_fix-SpooledTemporaryFile-IOBase branch from 54b6c7b to fba27e4 Compare December 6, 2021 01:26
@pR0Ps

pR0Ps commented Dec 6, 2021

Copy link
Copy Markdown
Contributor Author

Rebased on latest main.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pR0Ps
pR0Ps force-pushed the bpo-26175_fix-SpooledTemporaryFile-IOBase branch from fba27e4 to c6546f7 Compare December 13, 2021 04:05
@pR0Ps
pR0Ps force-pushed the bpo-26175_fix-SpooledTemporaryFile-IOBase branch from c6546f7 to ebb1d76 Compare December 21, 2021 18:05
@pR0Ps
pR0Ps force-pushed the bpo-26175_fix-SpooledTemporaryFile-IOBase branch from ebb1d76 to dbc85fd Compare December 31, 2021 05:18
@pR0Ps pR0Ps mentioned this pull request Dec 31, 2021
bpo-26175: Fix SpooledTemporaryFile IOBase abstract #3249
Closed
merwok
merwok reviewed Dec 31, 2021
View reviewed changes
Comment thread Lib/test/test_tempfile.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@pR0Ps @GFernie
Implement io.IOBase interface for SpooledTemporaryFile
b229469
Since the underlying file-like objects (either `io.BytesIO`,
`io.StringIO`, or a true file object) all implement the `io.IOBase`
interface, the `SpooledTemporaryFile` should as well.

Additionally, since the underlying file object will either be an
instance of an `io.BufferedIOBase` (for binary mode) or an
`io.TextIOBase` (for text mode), methods for these classes were also
implemented.

In every case, the required methods and properties are simply delegated
to the underlying file object.

Co-authored-by: Gary Fernie <[email protected]>
@pR0Ps
pR0Ps force-pushed the bpo-26175_fix-SpooledTemporaryFile-IOBase branch from dbc85fd to e66d4a3 Compare January 3, 2022 01:19
@merwok

merwok commented Jan 3, 2022

Copy link
Copy Markdown
Member

In the future, please avoid force pushes on Python repositories, they make reviewing less pleasant: https://devguide.python.org/pullrequest/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pR0Ps
Fix calling 'del' in tests
753aeb0
@pR0Ps
pR0Ps force-pushed the bpo-26175_fix-SpooledTemporaryFile-IOBase branch from e66d4a3 to 753aeb0 Compare January 3, 2022 02:22
@pR0Ps

pR0Ps commented Jan 3, 2022

Copy link
Copy Markdown
Contributor Author

In the future, please avoid force pushes on Python repositories, they make reviewing less pleasant: https://devguide.python.org/pullrequest/

Sorry, I've re-pushed the change as a separate commit and will do the same in the future.

merwok reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@arhadthedev

arhadthedev commented Jan 3, 2022

Copy link
Copy Markdown
Member

@pR0Ps Thanks! When PR is updated with a usual push, everybody subscribed can open the PR from "Unread notifications" and see only these updates of a diff. For example, a full PR4881073 contains 38 insertions but I do not need to reread it from a scratch after a (bunch of) commit(s) was added today:

image

Source: https://github.com/python/cpython/pull/29052/files/91f8ad6445a0671af6b0ee65cfba778c7ac150c4..d28a4ed7e24263972549ab82e6c7cf455e05defc

With a force-push, however, GitHub gives up and forces a reviewer to open a list of commits and manually scan for all changes:

image

When there are a few commits per day, it's ok. However, in this repo with a dosen of changes per hour, such manual works would become a second job.

pR0Ps reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

merwok
merwok reviewed Feb 21, 2022
View reviewed changes
Comment thread Lib/tempfile.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

merwok
merwok reviewed Feb 21, 2022
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2021-11-14-01-35-04.bpo-26175.LNlOfI.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

pR0Ps added 2 commits February 23, 2022 03:31
@pR0Ps
Apply suggestion from @merwok
d93781b
@pR0Ps
Revert improvement to truncate control flow
145668a
merwok
merwok reviewed Feb 24, 2022
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2021-11-14-01-35-04.bpo-26175.LNlOfI.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@pR0Ps
Added name to ACKs and patch notes
9ebd545
methane
methane approved these changes Mar 1, 2022
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Mar 1, 2022
@pR0Ps

pR0Ps commented May 2, 2022

Copy link
Copy Markdown
Contributor Author

@erlend-aasland Can you take a look please?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood AlexWaygood added the topic-IO label May 3, 2022
@methane
Merge branch 'main' into bpo-26175_fix-SpooledTemporaryFile-IOBase
3e3c8f1
@methane
methane merged commit 78e70be into python:main May 3, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label May 3, 2022
@GFernie GFernie mannequin mentioned this pull request May 3, 2022
Fully implement IOBase abstract on SpooledTemporaryFile #70363
Closed
@pR0Ps
pR0Ps deleted the bpo-26175_fix-SpooledTemporaryFile-IOBase branch May 3, 2022 17:09
JelleZijlstra added a commit to python/typeshed that referenced this pull request May 7, 2022
@JelleZijlstra
tempfile.SpooledTemporaryFile: inherit from IOBase on 3.11
52c19bf
python/cpython#29560
@JelleZijlstra JelleZijlstra mentioned this pull request May 7, 2022
tempfile.SpooledTemporaryFile: inherit from IOBase on 3.11 python/typeshed#7802
Merged
JelleZijlstra added a commit to python/typeshed that referenced this pull request May 18, 2022
@JelleZijlstra @AlexWaygood
tempfile.SpooledTemporaryFile: inherit from IOBase on 3.11 (#7802)
8f5a835
python/cpython#29560

Co-authored-by: Alex Waygood <[email protected]>
@arcondello arcondello mentioned this pull request Sep 16, 2022
Build wheels for Python 3.11 dwavesystems/dimod#1247
Merged
@CAM-Gerlach CAM-Gerlach mentioned this pull request Oct 16, 2022
gh-95913: Add io support for SpooledTemporaryFile in Whatsnew #98312
Merged
@Archmonger Archmonger mentioned this pull request Jun 16, 2025
AttributeError: 'SpooledTemporaryFile' object has no attribute 'readinto' Archmonger/django-dbbackup#378
Closed
This was referenced Sep 2, 2026
SpooledTemporaryFile.truncate returns None #89756
Closed
gh-89756: make SpooledTemporaryFile.truncate return new file size and improve documentation #29197
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@merwok merwok merwok left review comments
@methane methane methane approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

topic-IO

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@pR0Ps @the-knights-who-say-ni @ztane @merwok @arhadthedev @methane @bedevere-bot @AlexWaygood
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.