mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #11857 -- Added missing 'closed' property on TemporaryFile class.
- TemporaryFile now minimally mocks the API of the Python standard library class tempfile.NamedTemporaryFile to avoid AttributeError exceptions. - The symbol django.core.files.NamedTemporaryFile is actually assigned as a different class on different operating systems. - The bug only occurred if Django is running on Windows, hence why it was hard to diagnose.
This commit is contained in:
@@ -46,6 +46,15 @@ if os.name == 'nt':
|
||||
except (OSError):
|
||||
pass
|
||||
|
||||
@property
|
||||
def closed(self):
|
||||
"""
|
||||
This attribute needs to be accessible in certain situations,
|
||||
because this class is supposed to mock the API of the class
|
||||
tempfile.NamedTemporaryFile in the Python standard library.
|
||||
"""
|
||||
return self.file.closed
|
||||
|
||||
def __del__(self):
|
||||
self.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user