summaryrefslogtreecommitdiff
path: root/django/forms/fields.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/forms/fields.py')
-rw-r--r--django/forms/fields.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py
index 805018786a..9246676527 100644
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -9,7 +9,6 @@ import math
import os
import re
import uuid
-from contextlib import suppress
from decimal import Decimal, DecimalException
from io import BytesIO
from urllib.parse import urlsplit, urlunsplit
@@ -1093,7 +1092,7 @@ class FilePathField(ChoiceField):
f = os.path.join(root, f)
self.choices.append((f, f.replace(path, "", 1)))
else:
- with suppress(OSError):
+ try:
for f in sorted(os.listdir(self.path)):
if f == '__pycache__':
continue
@@ -1102,6 +1101,8 @@ class FilePathField(ChoiceField):
(self.allow_folders and os.path.isdir(full_file))) and
(self.match is None or self.match_re.search(f))):
self.choices.append((full_file, f))
+ except OSError:
+ pass
self.widget.choices = self.choices