Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replaced a hardcoded "2" with the right named constant

  • Loading branch information...
commit 4ad9f4d4eaeec0fc5bcd3cef029d49ca23975dba 1 parent ee48f4a
Alex Gaynor alex authored
Showing with 5 additions and 1 deletion.
  1. +5 −1 django/core/files/uploadedfile.py
6 django/core/files/uploadedfile.py
View
@@ -2,6 +2,7 @@
Classes representing uploaded files.
"""
+import errno
import os
from io import BytesIO
@@ -13,6 +14,7 @@
__all__ = ('UploadedFile', 'TemporaryUploadedFile', 'InMemoryUploadedFile',
'SimpleUploadedFile')
+
class UploadedFile(File):
"""
A abstract uploaded file (``TemporaryUploadedFile`` and
@@ -53,6 +55,7 @@ def _set_name(self, name):
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 @@ def close(self):
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).
Please sign in to comment.
Something went wrong with that request. Please try again.