-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
[3.9] bpo-40701: tempfile mixes str and bytes in an inconsistent manner (GH-20442) #24734
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
Conversation
…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>
|
Assigning to @ambv as release manager to decide if this counts as a bugfix for 3.9 or not. technically tempfile.gettempdir()'s API changes as it now always returns str. When in the past it blindly returned whatever tempfile.tempdir was set to when non-None. But that was mostly a bug as tempfile.tempdir being set to bytes didn't always work properly. and there is already a gettempdirb() function that explicitly returns bytes, implying that gettempdir() should be str. |
Doc/library/tempfile.rst
Outdated
| @@ -248,6 +248,11 @@ The module defines the following user-callable items: | |||
| The result of this search is cached, see the description of | |||
| :data:`tempdir` below. | |||
|
|
|||
| .. versionchanged:: 3.10 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if accepted in 3.9 as a bugfix, i'll update this to 3.9.5 or whatever is appropriate.
|
if you don't want this in 3.9, simply close the PR. :) |
|
This PR is stale because it has been open for 30 days with no activity. |
|
Can I do something to help the process? |
|
It is fixed in 3.10, the open question here is up to our 3.9 release manager @ambv to decide as to if this goes beyond a bug fix into behavior change territory. |
| explicit ``prefix``, ``suffix``, or ``dir`` arguments of type | ||
| str are supplied. Please do not write code expecting or | ||
| depending on this. This awkward behavior is maintained for | ||
| compatibility with the historcal implementation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
historical
|
Good change for 3.10, unclear if code in the wild isn't already using the wart of returning bytes from gettempdir(). Given that, it's cleaner to break compatibility with this API mistake on a new Python version. |
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
https://bugs.python.org/issue40701