Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-tri.struct for openSUSE:Factory checked in at 2021-01-25 18:23:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-tri.struct (Old) and /work/SRC/openSUSE:Factory/.python-tri.struct.new.28504 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-tri.struct" Mon Jan 25 18:23:33 2021 rev:2 rq:866161 version:4.0.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-tri.struct/python-tri.struct.changes 2019-09-05 12:42:43.543474516 +0200 +++ /work/SRC/openSUSE:Factory/.python-tri.struct.new.28504/python-tri.struct.changes 2021-01-25 18:23:52.424450739 +0100 @@ -1,0 +2,8 @@ +Fri Jan 22 15:38:04 UTC 2021 - Benjamin Greiner <[email protected]> + +- Update to v4.0.0 + * Split c implementation to separate FastStruct. The native + python implementation is now always the Struct +- Skip Python2 (syntax errors) + +------------------------------------------------------------------- Old: ---- tri.struct-3.1.0.tar.gz New: ---- tri.struct-4.0.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-tri.struct.spec ++++++ --- /var/tmp/diff_new_pack.tOLtVX/_old 2021-01-25 18:23:53.148451791 +0100 +++ /var/tmp/diff_new_pack.tOLtVX/_new 2021-01-25 18:23:53.152451797 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-tri.struct # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,23 +12,25 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# %{?!python_module:%define python_module() python-%{**} python3-%{**}} +%define skip_python2 1 Name: python-tri.struct -Version: 3.1.0 +Version: 4.0.0 Release: 0 -License: BSD-3-Clause Summary: Python dictionaries with attribute access -Url: https://github.com/TriOptima/tri.struct +License: BSD-3-Clause Group: Development/Languages/Python +URL: https://github.com/TriOptima/tri.struct Source: https://github.com/TriOptima/tri.struct/archive/%{version}.tar.gz#/tri.struct-%{version}.tar.gz -BuildRequires: python-rpm-macros BuildRequires: %{python_module devel} BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools} BuildRequires: fdupes +BuildRequires: python-rpm-macros %python_subpackages @@ -53,6 +55,7 @@ %files %{python_files} %doc AUTHORS.rst README.rst %license LICENSE -%{python_sitearch}/* +%{python_sitearch}/tri_struct +%{python_sitearch}/tri.struct-%{version}*-info %changelog ++++++ tri.struct-3.1.0.tar.gz -> tri.struct-4.0.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tri.struct-3.1.0/HISTORY.rst new/tri.struct-4.0.0/HISTORY.rst --- old/tri.struct-3.1.0/HISTORY.rst 2019-08-14 14:46:20.000000000 +0200 +++ new/tri.struct-4.0.0/HISTORY.rst 2020-08-20 13:19:54.000000000 +0200 @@ -1,5 +1,10 @@ Changelog --------- +4.0.0 (2020-12-20) +~~~~~~~~~~~~~~~~~~ + +* Split c implementation to separate `FastStruct`. The native python implementation is now always the `Struct` + 3.1.0 (2019-08-14) ~~~~~~~~~~~~~~~~~~ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tri.struct-3.1.0/Makefile new/tri.struct-4.0.0/Makefile --- old/tri.struct-3.1.0/Makefile 2019-08-14 14:46:20.000000000 +0200 +++ new/tri.struct-4.0.0/Makefile 2020-08-20 13:19:54.000000000 +0200 @@ -1,5 +1,7 @@ .PHONY: clean-pyc clean-build docs clean lint test coverage docs dist tag release-check +PYTHON ?= python + help: @echo "clean-build - remove build artifacts" @echo "clean-pyc - remove Python file artifacts" @@ -40,14 +42,12 @@ tox -e docs dist: clean - python2.7 setup.py sdist - python2.7 setup.py bdist_wheel - python3.6 setup.py bdist_wheel + $(PYTHON) setup.py sdist bdist_wheel ls -l dist tag: - python setup.py tag + $(PYTHON) setup.py tag release-check: - python setup.py release_check + $(PYTHON) setup.py release_check diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tri.struct-3.1.0/lib/tri_struct/__init__.py new/tri.struct-4.0.0/lib/tri_struct/__init__.py --- old/tri.struct-3.1.0/lib/tri_struct/__init__.py 2019-08-14 14:46:20.000000000 +0200 +++ new/tri.struct-4.0.0/lib/tri_struct/__init__.py 2020-08-20 13:19:54.000000000 +0200 @@ -1,12 +1,12 @@ from ._pystruct import Struct try: - from ._cstruct import _Struct as Struct # noqa + from ._cstruct import _Struct as FastStruct # noqa except ImportError: # pragma: no cover - pass + FastStruct = None -__version__ = '3.1.0' # pragma: no mutate -__all__ = ['Struct', 'FrozenStruct', 'merged', 'DefaultStruct', 'to_default_struct'] # pragma: no mutate +__version__ = '4.0.0' # pragma: no mutate +__all__ = ['Struct', 'FastStruct', 'FrozenStruct', 'merged', 'DefaultStruct', 'to_default_struct'] # pragma: no mutate class Frozen(object): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tri.struct-3.1.0/lib/tri_struct/_cstruct.c new/tri.struct-4.0.0/lib/tri_struct/_cstruct.c --- old/tri.struct-3.1.0/lib/tri_struct/_cstruct.c 2019-08-14 14:46:20.000000000 +0200 +++ new/tri.struct-4.0.0/lib/tri_struct/_cstruct.c 2020-08-20 13:19:54.000000000 +0200 @@ -251,7 +251,7 @@ static PyType_Spec StructType_spec = { - .name = "tri_struct.Struct", + .name = "tri_struct.FastStruct", .basicsize = sizeof(StructObject), .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_DICT_SUBCLASS | Py_TPFLAGS_HAVE_VERSION_TAG, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tri.struct-3.1.0/lib/tri_struct/_pystruct.py new/tri.struct-4.0.0/lib/tri_struct/_pystruct.py --- old/tri.struct-3.1.0/lib/tri_struct/_pystruct.py 2019-08-14 14:46:20.000000000 +0200 +++ new/tri.struct-4.0.0/lib/tri_struct/_pystruct.py 2020-08-20 13:19:54.000000000 +0200 @@ -37,7 +37,7 @@ __str__ = __repr__ def __getattribute__(self, item): - if item not in self: + if not dict.__contains__(self, item): try: return object.__getattribute__(self, item) except AttributeError as e: @@ -46,7 +46,7 @@ return missing_.__get__(self)(item) except AttributeError: raise e - return self[item] + return dict.__getitem__(self, item) def __setattr__(self, key, value): self[key] = value diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tri.struct-3.1.0/tests/test_struct.py new/tri.struct-4.0.0/tests/test_struct.py --- old/tri.struct-3.1.0/tests/test_struct.py 2019-08-14 14:46:20.000000000 +0200 +++ new/tri.struct-4.0.0/tests/test_struct.py 2020-08-20 13:19:54.000000000 +0200 @@ -3,19 +3,21 @@ import pytest -from tri_struct import FrozenStruct, merged, DefaultStruct, to_default_struct -from tri_struct._pystruct import Struct as PyStruct - -try: - from tri_struct._cstruct import _Struct as CStruct -except ImportError: - CStruct = None +from tri_struct import Struct as PyStruct +from tri_struct import ( + FastStruct, + Frozen, + FrozenStruct, + merged, + DefaultStruct, + to_default_struct, +) @pytest.fixture(scope="module", - params=filter(None, [CStruct, PyStruct]), - ids=[name for (name, cls) in [("CStruct", CStruct), - ("PyStruct", PyStruct)] + params=filter(None, [PyStruct, FastStruct]), + ids=[name for (name, cls) in [("Struct", PyStruct), + ("FastStruct", FastStruct)] if cls is not None]) def Struct(request): return request.param @@ -44,6 +46,16 @@ assert 1 == s.get('a') +def test_get_attr_broken_shadow(Struct): + # This is mostly to document the somewhat quirky behavior when shadowing __getitem__ + class MyStruct(Struct): + def __getitem__(self, key): + return 17 + + assert MyStruct(x=19)['x'] == 17 + assert MyStruct(x=19).x == 19 + + def test_set_item(Struct): s = Struct(a=1, b=2, c=3) s['a'] = 8 @@ -132,6 +144,9 @@ def test_hash(Struct): + if Struct is FastStruct: + pytest.skip('Does not work for FastStruct') + s = Struct(x=17) with pytest.raises(TypeError) as e: hash(s) @@ -140,6 +155,9 @@ else: assert "unhashable type: 'Struct'" in str(e.value) + class FrozenStruct(Frozen, Struct): + __slots__ = ('_hash', ) + f = FrozenStruct(x=17) assert isinstance(hash(f), int) assert '_hash' not in f.keys() @@ -162,20 +180,20 @@ def test_stable_str(Struct): - assert str(Struct(b=1, a=2)) == 'Struct(a=2, b=1)' + assert str(Struct(b=1, a=2)) == f'{Struct.__name__}(a=2, b=1)' def test_recursive_repr(Struct): s = Struct() s.s = s - assert str(s) == 'Struct(s=Struct(...))' + assert str(s) == f'{Struct.__name__}(s={Struct.__name__}(...))' # test fix for use-after-free s = Struct() s.a = s s.b = s - assert repr(s) == 'Struct(a=Struct(...), b=Struct(...))' + assert repr(s) == f'{Struct.__name__}(a={Struct.__name__}(...), b={Struct.__name__}(...))' def test_missing_method(Struct): @@ -194,36 +212,22 @@ # the missing method should be called for attr access, on missing attribute assert m.bar == 1 -## + # because of class name & module renaming, pickling the different # implementations won't, unless you also switch the tri_struct.Struct # implementation to match -## [email protected](CStruct is None, reason="CStruct not available") -def test_pickle_cstruct(): - import tri_struct [email protected](FastStruct is None, reason="CStruct not available") +def test_pickle_faststruct(): + s = FastStruct(x=17) + assert s == pickle.loads(pickle.dumps(s, pickle.HIGHEST_PROTOCOL)) + assert type(s) == type(pickle.loads(pickle.dumps(s, pickle.HIGHEST_PROTOCOL))) - _Struct = tri_struct.Struct - try: - tri_struct.Struct = CStruct - s = CStruct(x=17) - assert s == pickle.loads(pickle.dumps(s, pickle.HIGHEST_PROTOCOL)) - assert type(s) == type(pickle.loads(pickle.dumps(s, pickle.HIGHEST_PROTOCOL))) - finally: - tri_struct.Struct = _Struct - -def test_pickle_pystruct(): +def test_pickle_struct(): import tri_struct - - _Struct = tri_struct.Struct - try: - tri_struct.Struct = PyStruct - s = PyStruct(x=17) - assert s == pickle.loads(pickle.dumps(s, pickle.HIGHEST_PROTOCOL)) - assert type(s) == type(pickle.loads(pickle.dumps(s, pickle.HIGHEST_PROTOCOL))) - finally: - tri_struct.Struct = _Struct + s = tri_struct.Struct(x=17) + assert s == pickle.loads(pickle.dumps(s, pickle.HIGHEST_PROTOCOL)) + assert type(s) == type(pickle.loads(pickle.dumps(s, pickle.HIGHEST_PROTOCOL))) def test_frozen_struct(Struct): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tri.struct-3.1.0/tox.ini new/tri.struct-4.0.0/tox.ini --- old/tri.struct-3.1.0/tox.ini 2019-08-14 14:46:20.000000000 +0200 +++ new/tri.struct-4.0.0/tox.ini 2020-08-20 13:19:54.000000000 +0200 @@ -1,5 +1,5 @@ [tox] -envlist = py36, pypy3 +envlist = py37, py38, pypy3 [testenv] commands = {envpython} -m pytest {posargs} @@ -8,7 +8,7 @@ passenv = HOME [testenv:docs] -basepython = python3.6 +basepython = python3.7 usedevelop = True commands = rm -f docs/tri*.rst @@ -22,7 +22,7 @@ -rdocs/requirements.txt [testenv:coverage] -basepython = python3.6 +basepython = python3.7 usedevelop = True commands = {envpython} -m pytest --cov tri_struct --cov-config .coveragerc {posargs} @@ -34,17 +34,17 @@ -rtest_requirements.txt [testenv:lint] -basepython = python3.6 +basepython = python3.7 usedevelop = True commands = - {envpython} -m flake8 lib/tri tests setup.py {posargs} + {envpython} -m flake8 lib/tri_struct tests setup.py {posargs} deps = flake8 [testenv:venv] envdir = venv usedevelop = True -basepython = python3.6 +basepython = python3.8 commands = {posargs:python --version} deps = -rvenv_requirements.txt
