Skip to content

Commit eb0140b

Browse files
committed
Hidden __pycache__ dirs for FilePathField. Refs django#17393.
This will be tested as soon as tests will run under Python 3. Patch taken from Vinay Sajip's Python 3 branch.
1 parent aa757ac commit eb0140b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

django/forms/fields.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,12 +932,16 @@ def __init__(self, path, match=None, recursive=False, allow_files=True,
932932
self.choices.append((f, f.replace(path, "", 1)))
933933
if self.allow_folders:
934934
for f in dirs:
935+
if f == '__pycache__':
936+
continue
935937
if self.match is None or self.match_re.search(f):
936938
f = os.path.join(root, f)
937939
self.choices.append((f, f.replace(path, "", 1)))
938940
else:
939941
try:
940942
for f in sorted(os.listdir(self.path)):
943+
if f == '__pycache__':
944+
continue
941945
full_file = os.path.join(self.path, f)
942946
if (((self.allow_files and os.path.isfile(full_file)) or
943947
(self.allow_folders and os.path.isdir(full_file))) and

0 commit comments

Comments
 (0)