Ref #23919 -- Replaced some os.path usage with pathlib.Path.

This commit is contained in:
Tom 2017-07-21 21:33:26 +01:00 committed by Tim Graham
parent 5d923f2d8c
commit 11b8c30b9e
10 changed files with 54 additions and 57 deletions

View file

@ -1,6 +1,6 @@
import ipaddress
import os
import re
from pathlib import Path
from urllib.parse import urlsplit, urlunsplit
from django.core.exceptions import ValidationError
@ -480,7 +480,7 @@ class FileExtensionValidator:
self.code = code
def __call__(self, value):
extension = os.path.splitext(value.name)[1][1:].lower()
extension = Path(value.name).suffix[1:].lower()
if self.allowed_extensions is not None and extension not in self.allowed_extensions:
raise ValidationError(
self.message,