Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Replaced a hardcoded "2" with the right named constant

  • Loading branch information...
commit 4ad9f4d4eaeec0fc5bcd3cef029d49ca23975dba 1 parent ee48f4a
Alex Gaynor authored

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. 6  django/core/files/uploadedfile.py
6  django/core/files/uploadedfile.py
@@ -2,6 +2,7 @@
2 2
 Classes representing uploaded files.
3 3
 """
4 4
 
  5
+import errno
5 6
 import os
6 7
 from io import BytesIO
7 8
 
@@ -13,6 +14,7 @@
13 14
 __all__ = ('UploadedFile', 'TemporaryUploadedFile', 'InMemoryUploadedFile',
14 15
            'SimpleUploadedFile')
15 16
 
  17
+
16 18
 class UploadedFile(File):
17 19
     """
18 20
     A abstract uploaded file (``TemporaryUploadedFile`` and
@@ -53,6 +55,7 @@ def _set_name(self, name):
53 55
 
54 56
     name = property(_get_name, _set_name)
55 57
 
  58
+
56 59
 class TemporaryUploadedFile(UploadedFile):
57 60
     """
58 61
     A file uploaded to a temporary location (i.e. stream-to-disk).
@@ -75,12 +78,13 @@ def close(self):
75 78
         try:
76 79
             return self.file.close()
77 80
         except OSError as e:
78  
-            if e.errno != 2:
  81
+            if e.errno != errno.ENOENT:
79 82
                 # Means the file was moved or deleted before the tempfile
80 83
                 # could unlink it.  Still sets self.file.close_called and
81 84
                 # calls self.file.file.close() before the exception
82 85
                 raise
83 86
 
  87
+
84 88
 class InMemoryUploadedFile(UploadedFile):
85 89
     """
86 90
     A file uploaded into memory (i.e. stream-to-memory).

0 notes on commit 4ad9f4d

Please sign in to comment.
Something went wrong with that request. Please try again.