Hello community,
here is the log from the commit of package python-django-picklefield for
openSUSE:Factory checked in at 2020-06-10 00:51:36
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-django-picklefield (Old)
and /work/SRC/openSUSE:Factory/.python-django-picklefield.new.3606 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-django-picklefield"
Wed Jun 10 00:51:36 2020 rev:15 rq:812910 version:3.0.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-django-picklefield/python-django-picklefield.changes
2020-02-20 14:59:26.266765740 +0100
+++
/work/SRC/openSUSE:Factory/.python-django-picklefield.new.3606/python-django-picklefield.changes
2020-06-10 00:51:46.099471159 +0200
@@ -1,0 +2,10 @@
+Tue Jun 9 11:53:27 UTC 2020 - Ondřej Súkup <[email protected]>
+
+- update to 3.0.0
+ * Allowed default pickle protocol to be overriden using
+ the PICKLEFIELD_DEFAULT_PROTOCOL setting.
+ * Dropped support for Python 2.
+ * Added testing against Django 3.0.
+ * Dropped support for Django 1.11.
+
+-------------------------------------------------------------------
Old:
----
v2.1.1.tar.gz
New:
----
v3.0.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-django-picklefield.spec ++++++
--- /var/tmp/diff_new_pack.ABGPdR/_old 2020-06-10 00:51:48.443477291 +0200
+++ /var/tmp/diff_new_pack.ABGPdR/_new 2020-06-10 00:51:48.447477301 +0200
@@ -17,8 +17,9 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
+%define skip_python2 1
Name: python-django-picklefield
-Version: 2.1.1
+Version: 3.0.0
Release: 0
Summary: Pickled object field for Django
License: MIT
++++++ v2.1.1.tar.gz -> v3.0.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-picklefield-2.1.1/.travis.yml
new/django-picklefield-3.0.0/.travis.yml
--- old/django-picklefield-2.1.1/.travis.yml 2020-01-28 16:01:12.000000000
+0100
+++ new/django-picklefield-3.0.0/.travis.yml 2020-06-05 17:57:04.000000000
+0200
@@ -3,7 +3,6 @@
language: python
cache: pip
python:
- - 2.7
- 3.5
- 3.6
- 3.7
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-picklefield-2.1.1/README.rst
new/django-picklefield-3.0.0/README.rst
--- old/django-picklefield-2.1.1/README.rst 2020-01-28 16:01:12.000000000
+0100
+++ new/django-picklefield-3.0.0/README.rst 2020-06-05 17:57:04.000000000
+0200
@@ -162,6 +162,15 @@
Changes
-------
+Changes in version 3.0.0
+========================
+
+* Allowed default pickle protocol to be overriden using the
+ `PICKLEFIELD_DEFAULT_PROTOCOL` setting.
+* Dropped support for Python 2.
+* Added testing against Django 3.0.
+* Dropped support for Django 1.11.
+
Changes in version 2.1.0
========================
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-picklefield-2.1.1/picklefield/__init__.py
new/django-picklefield-3.0.0/picklefield/__init__.py
--- old/django-picklefield-2.1.1/picklefield/__init__.py 2020-01-28
16:01:12.000000000 +0100
+++ new/django-picklefield-3.0.0/picklefield/__init__.py 2020-06-05
17:57:04.000000000 +0200
@@ -7,6 +7,6 @@
__all__ = 'VERSION', '__version__', 'DEFAULT_PROTOCOL', 'PickledObjectField'
-VERSION = (2, 1, 1, 'final', 0)
+VERSION = (3, 0, 0, 'final', 0)
__version__ = django.utils.version.get_version(VERSION)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-picklefield-2.1.1/picklefield/constants.py
new/django-picklefield-3.0.0/picklefield/constants.py
--- old/django-picklefield-2.1.1/picklefield/constants.py 2020-01-28
16:01:12.000000000 +0100
+++ new/django-picklefield-3.0.0/picklefield/constants.py 2020-06-05
17:57:04.000000000 +0200
@@ -1,3 +1 @@
-from __future__ import unicode_literals
-
DEFAULT_PROTOCOL = 2
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-picklefield-2.1.1/picklefield/fields.py
new/django-picklefield-3.0.0/picklefield/fields.py
--- old/django-picklefield-2.1.1/picklefield/fields.py 2020-01-28
16:01:12.000000000 +0100
+++ new/django-picklefield-3.0.0/picklefield/fields.py 2020-06-05
17:57:04.000000000 +0200
@@ -1,21 +1,15 @@
-from __future__ import unicode_literals
-
from base64 import b64decode, b64encode
from copy import deepcopy
+from pickle import dumps, loads
from zlib import compress, decompress
-from django import VERSION as DJANGO_VERSION
+from django.conf import settings
from django.core import checks
from django.db import models
-from django.utils.encoding import force_text
+from django.utils.encoding import force_str
from .constants import DEFAULT_PROTOCOL
-try:
- from cPickle import loads, dumps # pragma: no cover
-except ImportError:
- from pickle import loads, dumps # pragma: no cover
-
class PickledObject(str):
"""
@@ -31,7 +25,7 @@
"""
-class _ObjectWrapper(object):
+class _ObjectWrapper:
"""
A class used to wrap object that have properties that may clash with the
ORM internals.
@@ -52,13 +46,19 @@
return obj
-def dbsafe_encode(value, compress_object=False,
pickle_protocol=DEFAULT_PROTOCOL, copy=True):
+def get_default_protocol():
+ return getattr(settings, 'PICKLEFIELD_DEFAULT_PROTOCOL', DEFAULT_PROTOCOL)
+
+
+def dbsafe_encode(value, compress_object=False, pickle_protocol=None,
copy=True):
# We use deepcopy() here to avoid a problem with cPickle, where dumps
# can generate different character streams for same lookup value if
# they are referenced differently.
# The reason this is important is because we do all of our lookups as
# simple string matches, thus the character streams must be the same
# for the lookups to work properly. See tests.py for more information.
+ if pickle_protocol is None:
+ pickle_protocol = get_default_protocol()
if copy:
# Copy can be very expensive if users aren't going to perform lookups
# on the value anyway.
@@ -92,10 +92,13 @@
def __init__(self, *args, **kwargs):
self.compress = kwargs.pop('compress', False)
- self.protocol = kwargs.pop('protocol', DEFAULT_PROTOCOL)
+ protocol = kwargs.pop('protocol', None)
+ if protocol is None:
+ protocol = get_default_protocol()
+ self.protocol = protocol
self.copy = kwargs.pop('copy', True)
kwargs.setdefault('editable', False)
- super(PickledObjectField, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
def get_default(self):
"""
@@ -114,7 +117,7 @@
return self.default()
return self.default
# If the field doesn't have a default, then we punt to models.Field.
- return super(PickledObjectField, self).get_default()
+ return super().get_default()
def _check_default(self):
if self.has_default() and isinstance(self.default, (list, dict, set)):
@@ -139,10 +142,18 @@
return []
def check(self, **kwargs):
- errors = super(PickledObjectField, self).check(**kwargs)
+ errors = super().check(**kwargs)
errors.extend(self._check_default())
return errors
+ def deconstruct(self):
+ name, path, args, kwargs = super().deconstruct()
+ if self.compress:
+ kwargs['compress'] = True
+ if self.protocol != get_default_protocol():
+ kwargs['protocol'] = self.protocol
+ return name, path, args, kwargs
+
def to_python(self, value):
"""
B64decode and unpickle the object, optionally decompressing it.
@@ -167,15 +178,11 @@
return value
def pre_save(self, model_instance, add):
- value = super(PickledObjectField, self).pre_save(model_instance, add)
+ value = super().pre_save(model_instance, add)
return wrap_conflictual_object(value)
- if DJANGO_VERSION < (2, 0):
- def from_db_value(self, value, expression, connection, context): #
pragma: no cover
- return self.to_python(value) # pragma: no cover
- else:
- def from_db_value(self, value, expression, connection): # pragma: no
cover
- return self.to_python(value) # pragma: no cover
+ def from_db_value(self, value, expression, connection):
+ return self.to_python(value)
def get_db_prep_value(self, value, connection=None, prepared=False):
"""
@@ -189,13 +196,13 @@
"""
if value is not None and not isinstance(value, PickledObject):
- # We call force_text here explicitly, so that the encoded string
+ # We call force_str here explicitly, so that the encoded string
# isn't rejected by the postgresql_psycopg2 backend. Alternatively,
# we could have just registered PickledObject with the psycopg
# marshaller (telling it to store it like it would a string), but
# since both of these methods result in the same value being
stored,
# doing things this way is much easier.
- value = force_text(dbsafe_encode(value, self.compress,
self.protocol, self.copy))
+ value = force_str(dbsafe_encode(value, self.compress,
self.protocol, self.copy))
return value
def value_to_string(self, obj):
@@ -211,4 +218,4 @@
"""
if lookup_name not in ['exact', 'in', 'isnull']:
raise TypeError('Lookup type %s is not supported.' % lookup_name)
- return super(PickledObjectField, self).get_lookup(lookup_name)
+ return super().get_lookup(lookup_name)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-picklefield-2.1.1/setup.cfg
new/django-picklefield-3.0.0/setup.cfg
--- old/django-picklefield-2.1.1/setup.cfg 2020-01-28 16:01:12.000000000
+0100
+++ new/django-picklefield-3.0.0/setup.cfg 2020-06-05 17:57:04.000000000
+0200
@@ -6,6 +6,3 @@
include_trailing_comma=true
multi_line_output=5
not_skip=__init__.py
-
-[wheel]
-universal = 1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-picklefield-2.1.1/setup.py
new/django-picklefield-3.0.0/setup.py
--- old/django-picklefield-2.1.1/setup.py 2020-01-28 16:01:12.000000000
+0100
+++ new/django-picklefield-3.0.0/setup.py 2020-06-05 17:57:04.000000000
+0200
@@ -22,12 +22,12 @@
'Framework :: Django',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.2',
+ 'Framework :: Django :: 3.0',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
- 'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
@@ -38,6 +38,7 @@
],
keywords=['django pickle model field'],
packages=find_packages(exclude=['tests', 'tests.*']),
+ python_requires='>=3',
install_requires=['Django>=1.11'],
extras_require={
'tests': ['tox'],
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-picklefield-2.1.1/tests/models.py
new/django-picklefield-3.0.0/tests/models.py
--- old/django-picklefield-2.1.1/tests/models.py 2020-01-28
16:01:12.000000000 +0100
+++ new/django-picklefield-3.0.0/tests/models.py 2020-06-05
17:57:04.000000000 +0200
@@ -1,5 +1,3 @@
-from __future__ import unicode_literals
-
from datetime import date
from django.db import models
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-picklefield-2.1.1/tests/settings.py
new/django-picklefield-3.0.0/tests/settings.py
--- old/django-picklefield-2.1.1/tests/settings.py 2020-01-28
16:01:12.000000000 +0100
+++ new/django-picklefield-3.0.0/tests/settings.py 2020-06-05
17:57:04.000000000 +0200
@@ -1,5 +1,3 @@
-from __future__ import unicode_literals
-
SECRET_KEY = 'not-anymore'
DATABASES = {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-picklefield-2.1.1/tests/tests.py
new/django-picklefield-3.0.0/tests/tests.py
--- old/django-picklefield-2.1.1/tests/tests.py 2020-01-28 16:01:12.000000000
+0100
+++ new/django-picklefield-3.0.0/tests/tests.py 2020-06-05 17:57:04.000000000
+0200
@@ -1,5 +1,6 @@
import json
from datetime import date
+from unittest.mock import patch
from django.core import checks, serializers
from django.db import IntegrityError, models
@@ -14,18 +15,13 @@
TestCustomDataType, TestingModel,
)
-try:
- from unittest.mock import patch # pragma: no cover
-except ImportError:
- from mock import patch # pragma: no cover
-
class PickledObjectFieldTests(TestCase):
def setUp(self):
self.testing_data = (D2, S1, T1, L1,
TestCustomDataType(S1),
MinimalTestingModel)
- return super(PickledObjectFieldTests, self).setUp()
+ return super().setUp()
def test_data_integrity(self):
"""
@@ -203,6 +199,17 @@
self.assertEqual(encoded_value,
MinimalTestingModel.objects.get(pk=model.pk).pickle_field)
+class PickledObjectFieldDeconstructTests(SimpleTestCase):
+ def test_protocol(self):
+ field = PickledObjectField()
+ self.assertNotIn('protocol', field.deconstruct()[3])
+ with self.settings(PICKLEFIELD_DEFAULT_PROTOCOL=3):
+ field = PickledObjectField(protocol=4)
+ self.assertEqual(field.deconstruct()[3].get('protocol'), 4)
+ field = PickledObjectField(protocol=3)
+ self.assertNotIn('protocol', field.deconstruct()[3])
+
+
@isolate_apps('tests')
class PickledObjectFieldCheckTests(SimpleTestCase):
def test_mutable_default_check(self):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-picklefield-2.1.1/tox.ini
new/django-picklefield-3.0.0/tox.ini
--- old/django-picklefield-2.1.1/tox.ini 2020-01-28 16:01:12.000000000
+0100
+++ new/django-picklefield-3.0.0/tox.ini 2020-06-05 17:57:04.000000000
+0200
@@ -4,14 +4,12 @@
envlist =
flake8,
isort,
- py27-1.11,
- py35-{1.11,2.2},
- py36-{1.11,2.2,master},
- py37-{1.11,2.2,master},
- py38-{2.2,master},
+ py35-2.2,
+ py36-{2.2,3.0,master},
+ py37-{2.2,3.0,master},
+ py38-{2.2,3.0,master},
[tox:travis]
-2.7 = py27
3.5 = py35
3.6 = py36
3.7 = py37
@@ -19,7 +17,6 @@
[testenv]
basepython =
- py27: python2.7
py35: python3.5
py36: python3.6
py37: python3.7
@@ -29,22 +26,19 @@
{envpython} -R -Wonce {envbindir}/coverage run --branch -m django test -v2
--settings=tests.settings {posargs}
coverage report -m
deps =
- py27: mock
coverage
- 1.11: Django>=1.11,<2.0
- 2.0: Django>=2.0,<2.1
- 2.1: Django>=2.1,<2.2
2.2: Django>=2.2,<3.0
+ 3.0: Django>=3.0,<3.1
master: https://github.com/django/django/archive/master.tar.gz
[testenv:flake8]
usedevelop = false
-basepython = python2.7
+basepython = python3.6
commands = flake8
deps = flake8
[testenv:isort]
usedevelop = false
-basepython = python2.7
+basepython = python3.6
commands = isort --recursive --check-only --diff picklefield tests
deps = isort==4.2.5