Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added error handling at import django.utils.six module. #758 #759

Merged
merged 1 commit into from Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions storages/backends/apache_libcloud.py
Expand Up @@ -9,8 +9,13 @@
from django.core.files.base import File
from django.core.files.storage import Storage
from django.utils.deconstruct import deconstructible
from django.utils.six import string_types
from django.utils.six.moves.urllib.parse import urljoin

try:
from django.utils.six import string_types
from django.utils.six.moves.urllib.parse import urljoin
except ImportError:
string_types = str
from urllib.parse import urljoin

try:
from libcloud.storage.providers import get_driver
Expand Down
6 changes: 5 additions & 1 deletion storages/backends/ftp.py
Expand Up @@ -24,10 +24,14 @@
from django.core.files.base import File
from django.core.files.storage import Storage
from django.utils.deconstruct import deconstructible
from django.utils.six.moves.urllib import parse as urlparse

from storages.utils import setting

try:
from django.utils.six.moves.urllib import parse as urlparse
except ImportError:
from urllib import parse as urlparse


class FTPStorageException(Exception):
pass
Expand Down
7 changes: 6 additions & 1 deletion storages/backends/s3boto3.py
Expand Up @@ -15,14 +15,19 @@
from django.utils.encoding import (
filepath_to_uri, force_bytes, force_text, smart_text,
)
from django.utils.six.moves.urllib import parse as urlparse
from django.utils.timezone import is_naive, make_naive

from storages.utils import (
check_location, get_available_overwrite_name, lookup_env, safe_join,
setting,
)

try:
from django.utils.six.moves.urllib import parse as urlparse
except ImportError:
from urllib import parse as urlparse


try:
import boto3.session
from boto3 import __version__ as boto3_version
Expand Down
6 changes: 5 additions & 1 deletion storages/backends/sftpstorage.py
Expand Up @@ -16,10 +16,14 @@
from django.core.files.base import File
from django.core.files.storage import Storage
from django.utils.deconstruct import deconstructible
from django.utils.six.moves.urllib import parse as urlparse

from storages.utils import setting

try:
from django.utils.six.moves.urllib import parse as urlparse
except ImportError:
from urllib import parse as urlparse


@deconstructible
class SFTPStorage(Storage):
Expand Down
6 changes: 5 additions & 1 deletion tests/test_s3boto.py
Expand Up @@ -12,10 +12,14 @@
from django.core.files.base import ContentFile
from django.test import TestCase
from django.utils import timezone as tz
from django.utils.six.moves.urllib import parse as urlparse

from storages.backends import s3boto

try:
from django.utils.six.moves.urllib import parse as urlparse
except ImportError:
from urllib import parse as urlparse


class S3BotoTestCase(TestCase):
@mock.patch('storages.backends.s3boto.S3Connection')
Expand Down
7 changes: 6 additions & 1 deletion tests/test_s3boto3.py
Expand Up @@ -13,11 +13,16 @@
from django.core.exceptions import ImproperlyConfigured
from django.core.files.base import ContentFile
from django.test import TestCase, override_settings
from django.utils.six.moves.urllib import parse as urlparse
from django.utils.timezone import is_aware, utc

from storages.backends import s3boto3

try:
from django.utils.six.moves.urllib import parse as urlparse
except ImportError:
from urllib import parse as urlparse


try:
from unittest import mock
except ImportError: # Python 3.2 and below
Expand Down