diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-11-02 12:55:36 -0700 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-11-02 12:55:36 -0700 |
| commit | 4ad9f4d4eaeec0fc5bcd3cef029d49ca23975dba (patch) | |
| tree | ac6346ee7bb9c88c03f5ae79166a762fcbb13f37 /django | |
| parent | ee48f4af99a8b5666339f927c459253f9f98e91f (diff) | |
Replaced a hardcoded "2" with the right named constant
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/files/uploadedfile.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/django/core/files/uploadedfile.py b/django/core/files/uploadedfile.py index 0b632d39a7..b53a502068 100644 --- a/django/core/files/uploadedfile.py +++ b/django/core/files/uploadedfile.py @@ -2,6 +2,7 @@ Classes representing uploaded files. """ +import errno import os from io import BytesIO @@ -13,6 +14,7 @@ from django.utils.encoding import force_str __all__ = ('UploadedFile', 'TemporaryUploadedFile', 'InMemoryUploadedFile', 'SimpleUploadedFile') + class UploadedFile(File): """ A abstract uploaded file (``TemporaryUploadedFile`` and @@ -53,6 +55,7 @@ class UploadedFile(File): name = property(_get_name, _set_name) + class TemporaryUploadedFile(UploadedFile): """ A file uploaded to a temporary location (i.e. stream-to-disk). @@ -75,12 +78,13 @@ class TemporaryUploadedFile(UploadedFile): try: return self.file.close() except OSError as e: - if e.errno != 2: + if e.errno != errno.ENOENT: # Means the file was moved or deleted before the tempfile # could unlink it. Still sets self.file.close_called and # calls self.file.file.close() before the exception raise + class InMemoryUploadedFile(UploadedFile): """ A file uploaded into memory (i.e. stream-to-memory). |
