Kaydet (Commit) 4ad9f4d4 authored tarafından Alex Gaynor's avatar Alex Gaynor

Replaced a hardcoded "2" with the right named constant

üst ee48f4af
......@@ -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).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment