-
-
Notifications
You must be signed in to change notification settings - Fork 34.8k
gh-152586: Make tempfile.TemporaryFileWrapper public
#152646
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
Changes from all commits
62407c9
4fcba67
38db57f
a790753
c30d7a2
0a2d25a
4e67a01
4d7826e
da8b633
2dde1bd
88b8b4b
a63ce6d
efc960f
8f62957
dd1b9a3
375a717
c91fad4
3acc5a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ | |
| "TMP_MAX", "gettempprefix", # constants | ||
| "tempdir", "gettempdir", | ||
| "gettempprefixb", "gettempdirb", | ||
| "TemporaryFileWrapper", | ||
| ] | ||
|
|
||
|
|
||
|
|
@@ -484,7 +485,7 @@ def __del__(self): | |
| _warnings.warn(self.warn_message, ResourceWarning) | ||
|
|
||
|
|
||
| class _TemporaryFileWrapper: | ||
| class TemporaryFileWrapper: | ||
| """Temporary file wrapper | ||
|
|
||
| This class provides a wrapper around files opened for | ||
|
|
@@ -555,6 +556,19 @@ def __iter__(self): | |
| for line in self.file: | ||
| yield line | ||
|
|
||
| def __getattr__(name): | ||
| if name == "_TemporaryFileWrapper": | ||
| _warnings._deprecated( | ||
| "tempfile._TemporaryFileWrapper", | ||
| message=( | ||
| "{name!r} is deprecated and slated for removal in Python {remove}. " | ||
| "Use tempfile.TemporaryFileWrapper instead." | ||
| ), | ||
| remove=(3, 21), | ||
| ) | ||
| return TemporaryFileWrapper | ||
| raise AttributeError(f"module {__name__!r} has no attribute {name!r}") | ||
|
|
||
| def NamedTemporaryFile(mode='w+b', buffering=-1, encoding=None, | ||
| newline=None, suffix=None, prefix=None, | ||
| dir=None, delete=True, *, errors=None, | ||
|
|
@@ -607,7 +621,7 @@ def opener(*args): | |
| raw = getattr(file, 'buffer', file) | ||
| raw = getattr(raw, 'raw', raw) | ||
| raw.name = name | ||
| return _TemporaryFileWrapper(file, name, delete, delete_on_close) | ||
| return TemporaryFileWrapper(file, name, delete, delete_on_close) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for pointing out |
||
| except: | ||
| file.close() | ||
| raise | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| :class:`!tempfile._TemporaryFileWrapper` has been renamed to the public :class:`tempfile.TemporaryFileWrapper`. The old private name is kept as a deprecated alias and will be removed in Python 3.21. |
Uh oh!
There was an error while loading. Please reload this page.