Skip to content
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

bpo-40701: tempfile mixes str and bytes in an inconsistent manner #20442

Merged
merged 5 commits into from Mar 3, 2021

Conversation

ericzolf
Copy link
Contributor

@ericzolf ericzolf commented May 27, 2020

the case of tempdir variable being bytes is now handled consistently.
The getters return the right type and no more error of mixing str and
bytes unless explicitly caused by the user.

https://bugs.python.org/issue40701

https://bugs.python.org/issue40701

the case of tempdir variable being bytes is now handled consistently.
The getters return the right type and no more error of mixing str and
bytes unless explicitly caused by the user.
@the-knights-who-say-ni
Copy link

the-knights-who-say-ni commented May 27, 2020

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).

Recognized GitHub username

We couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames:

@ericzolf

This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

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

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

Lib/tempfile.py Outdated Show resolved Hide resolved
Lib/tempfile.py Outdated Show resolved Hide resolved
Lib/tempfile.py Outdated Show resolved Hide resolved
@ericzolf
Copy link
Contributor Author

ericzolf commented Mar 2, 2021

Is something missing from me to get this PR merged? It appears that the issue is even worse under Windows as it fails even on an existing bytes tempdir which exists, the reason being TemporaryFile is equal to NamedTemporaryFile. And it appeared that the latter also fails under Linux. See rdiff-backup/rdiff-backup#540 for details.

I would actually really appreciate a backport to 3.9 as well.

@gpshead gpshead self-assigned this Mar 2, 2021
@gpshead gpshead added the type-bug An unexpected behavior, bug, or error label Mar 2, 2021
gpshead
gpshead approved these changes Mar 2, 2021
Copy link
Member

@gpshead gpshead left a comment

I updated the documentation and added a unittest.

@gpshead
Copy link
Member

gpshead commented Mar 3, 2021

I can't merge this until the CI infrastructure issues are fixed.

@gpshead gpshead added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 3, 2021
@bedevere-bot
Copy link

bedevere-bot commented Mar 3, 2021

🤖 New build scheduled with the buildbot fleet by @gpshead for commit 4cb2127 🤖

If you want to schedule another build, you need to add the "🔨 test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 3, 2021
@gpshead gpshead closed this Mar 3, 2021
@gpshead gpshead reopened this Mar 3, 2021
@gpshead gpshead merged commit 9c79274 into python:master Mar 3, 2021
74 of 78 checks passed
@miss-islington
Copy link
Contributor

miss-islington commented Mar 3, 2021

Thanks @ericzolf for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒🤖

@bedevere-bot
Copy link

bedevere-bot commented Mar 3, 2021

GH-24734 is a backport of this pull request to the 3.9 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 3, 2021
…thonGH-20442)

The case of tempfile.tempdir variable being bytes is now handled consistently.
The getters return the right type and no more error of mixing str and bytes unless explicitly caused by the user.

Adds a regression test.

Expands the documentation to clarify the behavior.

Co-authored-by: Eric L <ewl+git@lavar.de>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
(cherry picked from commit 9c79274)

Co-authored-by: Eric L <ericzolf@users.noreply.github.com>
kreathon pushed a commit to kreathon/cpython that referenced this pull request May 2, 2021
…thonGH-20442)

The case of tempfile.tempdir variable being bytes is now handled consistently.
The getters return the right type and no more error of mixing str and bytes unless explicitly caused by the user.

Adds a regression test.

Expands the documentation to clarify the behavior.

Co-authored-by: Eric L <ewl+git@lavar.de>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants