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

Replace force_text with force_str for django >= 3 #27

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion fernet_fields/fields.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from cryptography.fernet import Fernet, MultiFernet

from django.conf import settings
from django.core.exceptions import FieldError, ImproperlyConfigured
from django.db import models
from django.utils.encoding import force_bytes, force_text
from django.utils.encoding import force_bytes
from django.utils.functional import cached_property

from .utils import force_text
from . import hkdf


Expand Down
9 changes: 6 additions & 3 deletions fernet_fields/test/test_fields.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from cryptography.fernet import Fernet
from datetime import date, datetime

import pytest
from cryptography.fernet import Fernet

from django.core.exceptions import FieldError, ImproperlyConfigured
from django.db import connection, models as dj_models
from django.utils.encoding import force_bytes, force_text
import pytest
from django.utils.encoding import force_bytes

import fernet_fields as fields
from fernet_fields.utils import force_text

from . import models


Expand Down
7 changes: 7 additions & 0 deletions fernet_fields/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django import VERSION as DJANGO_VERSION


if DJANGO_VERSION[0] < 3:
from django.utils.encoding import force_text
else:
from django.utils.encoding import force_str as force_text
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
envlist =
py36-{docs,flake8},
py{27,35,36,37,py}-django111-{pg,sqlite},
py{35,36,37}-{django21,django22,djangolatest}-{pg,sqlite},
py{35,36,37}-{django21,django22,django30,djangolatest}-{pg,sqlite},
flake8,
docs

Expand All @@ -20,7 +20,8 @@ deps =
django111: Django>=1.11,<2
django21: Django>=2.1,<2.2
django22: Django>=2.2,<2.3
djangolatest: Django>=2.2
django30: Django>=3.0,<3.1
djangolatest: Django>=3.0

# Older PyPy versions (and all released PyPy3 versions) don't work with cryptography 1.0
py{py,py3}: cryptography<1
Expand Down