Accepting request 506524 from home:alois:branches:devel:languages:python

OBS-URL: https://build.opensuse.org/request/show/506524
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-persistent?expand=0&rev=7
This commit is contained in:
Hans-Peter Jansen 2017-06-29 08:42:25 +00:00 committed by Git OBS Bridge
parent 0356b6357d
commit c5faae2ac8
5 changed files with 100 additions and 169 deletions

View File

@ -1,131 +0,0 @@
fix timestamp hash computation on 32-bit platform.
Patch extracted from PR #22 and #23, see:
https://github.com/zopefoundation/persistent/issues/21
https://github.com/zopefoundation/persistent/pull/22
https://github.com/zopefoundation/persistent/pull/23
---
persistent/tests/test_timestamp.py | 64 +++++++++++++++++++++++++++++++++----
persistent/timestamp.py | 4 +-
2 files changed, 60 insertions(+), 8 deletions(-)
Index: persistent-4.0.9/persistent/tests/test_timestamp.py
===================================================================
--- persistent-4.0.9.orig/persistent/tests/test_timestamp.py
+++ persistent-4.0.9/persistent/tests/test_timestamp.py
@@ -253,9 +253,45 @@ class PyAndCComparisonTests(unittest.Tes
c, py = self._make_C_and_Py(*self.now_ts_args)
self.assertEqual(hash(c), hash(py))
+ def test_py_hash_32_64_bit(self):
+ # We happen to know that on a 32-bit platform, the hashcode
+ # of the c version should be exactly
+ # -1419374591
+ # and the 64-bit should be exactly:
+ # -3850693964765720575
+ # Fake out the python version to think it's on a 32-bit
+ # platform and test the same; also verify 64 bit
+ bit_32_hash = -1419374591
+ bit_64_hash = -3850693964765720575
+ import persistent.timestamp
+ import ctypes
+ orig_c_long = persistent.timestamp.c_long
+ try:
+ persistent.timestamp.c_long = ctypes.c_int32
+ py = self._makePy(*self.now_ts_args)
+ self.assertEqual(hash(py), bit_32_hash)
+
+ persistent.timestamp.c_long = ctypes.c_int64
+ # call __hash__ directly to avoid interpreter truncation
+ # in hash() on 32-bit platforms
+ self.assertEqual(py.__hash__(), bit_64_hash)
+ finally:
+ persistent.timestamp.c_long = orig_c_long
+
+ if orig_c_long is ctypes.c_int32:
+ self.assertEqual(py.__hash__(), bit_32_hash)
+ elif orig_c_long is ctypes.c_int64:
+ self.assertEqual(py.__hash__(), bit_64_hash)
+ else:
+ self.fail("Unknown bitness")
+
def test_hash_equal_constants(self):
# The simple constants make it easier to diagnose
# a difference in algorithms
+ import persistent.timestamp
+ import ctypes
+ is_32_bit = persistent.timestamp.c_long == ctypes.c_int32
+
c, py = self._make_C_and_Py(b'\x00\x00\x00\x00\x00\x00\x00\x00')
self.assertEqual(hash(c), 8)
self.assertEqual(hash(c), hash(py))
@@ -268,25 +304,41 @@ class PyAndCComparisonTests(unittest.Tes
self.assertEqual(hash(c), 1000011)
self.assertEqual(hash(c), hash(py))
+ # overflow kicks in here on 32-bit platforms
c, py = self._make_C_and_Py(b'\x00\x00\x00\x00\x00\x01\x00\x00')
- self.assertEqual(hash(c), 1000006000001)
+ if is_32_bit:
+ self.assertEqual(hash(c), -721379967)
+ else:
+ self.assertEqual(hash(c), 1000006000001)
self.assertEqual(hash(c), hash(py))
c, py = self._make_C_and_Py(b'\x00\x00\x00\x00\x01\x00\x00\x00')
- self.assertEqual(hash(c), 1000009000027000019)
+ if is_32_bit:
+ self.assertEqual(hash(c), 583896275)
+ else:
+ self.assertEqual(hash(c), 1000009000027000019)
self.assertEqual(hash(c), hash(py))
- # Overflow kicks in at this point
+ # Overflow kicks in at this point on 64-bit platforms
c, py = self._make_C_and_Py(b'\x00\x00\x00\x01\x00\x00\x00\x00')
- self.assertEqual(hash(c), -4442925868394654887)
+ if is_32_bit:
+ self.assertEqual(hash(c), 1525764953)
+ else:
+ self.assertEqual(hash(c), -4442925868394654887)
self.assertEqual(hash(c), hash(py))
c, py = self._make_C_and_Py(b'\x00\x00\x01\x00\x00\x00\x00\x00')
- self.assertEqual(hash(c), -3993531167153147845)
+ if is_32_bit:
+ self.assertEqual(hash(c), -429739973)
+ else:
+ self.assertEqual(hash(c), -3993531167153147845)
self.assertEqual(hash(c), hash(py))
c, py = self._make_C_and_Py(b'\x01\x00\x00\x00\x00\x00\x00\x00')
- self.assertEqual(hash(c), -3099646879006235965)
+ if is_32_bit:
+ self.assertEqual(hash(c), 263152323)
+ else:
+ self.assertEqual(hash(c), -3099646879006235965)
self.assertEqual(hash(c), hash(py))
def test_ordering(self):
Index: persistent-4.0.9/persistent/timestamp.py
===================================================================
--- persistent-4.0.9.orig/persistent/timestamp.py
+++ persistent-4.0.9/persistent/timestamp.py
@@ -13,7 +13,7 @@
##############################################################################
__all__ = ('TimeStamp',)
-from ctypes import c_int64
+from ctypes import c_long
import datetime
import math
import struct
@@ -158,7 +158,7 @@ class pyTimeStamp(object):
# Make sure to overflow and wraparound just
# like the C code does.
- x = c_int64(x).value
+ x = c_long(x).value
if x == -1: #pragma: no cover
# The C version has this condition, but it's not clear
# why; it's also not immediately obvious what bytestring

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c64f2efc2b40cce38a0683ef7ca715afeb1d69a156619d454462f0e1861cf28a
size 675350

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:cf264cd55866c7ffbcbe1328f8d8b28fd042a5dd0c03a03f68c0887df3aa1964
size 96135

View File

@ -1,3 +1,64 @@
-------------------------------------------------------------------
Sat Jun 24 11:10:40 UTC 2017 - aloisio@gmx.com
- Update to 4.2.4.2
* Packaging-only release: fix Python 2.7 manylinux wheels.
4.2.4.1:
* Packaging-only release: get manylinux wheel built
automatically.
4.2.4:
* Avoid raising a SystemError: error return without exception
set when loading an object with slots whose jar generates an
exception (such as a ZODB POSKeyError) in setstate.
4.2.3:
* Fix the hashcode of Python TimeStamp objects on 64-bit
Python on Windows. See
https://github.com/zopefoundation/persistent/pull/55
* Stop calling gc.collect every time PickleCache.incrgc is
called (every transaction boundary) in pure-Python mode (PyPy).
This means that the reported size of the cache may be wrong
(until the next GC), but it is much faster. This should not
have any observable effects for user code.
* Stop clearing the dict and slots of objects added to
PickleCache.new_ghost (typically these values are passed to
__new__ from the pickle data) in pure-Python mode (PyPy). This
matches the behaviour of the C code.
* Add support for Python 3.6.
* Fix __setstate__ interning when state parameter is not a
built-in dict
4.2.2:
* Drop use of ctypes for determining maximum integer size, to
increase pure-Python compatibility. See
https://github.com/zopefoundation/persistent/pull/31
* Ensure that __slots__ attributes are cleared when a
persistent object is ghostified. (This excluses classes that
override __new__. See
https://github.com/zopefoundation/persistent/wiki/Notes_on_state_
new_and_slots if youre curious.)
4.2.1:
* Fix the hashcode of C TimeStamp objects on 64-bit Python 3
on Windows.
4.2.0:
* Fixed the Python(/PYPY) implementation TimeStamp.timeTime
method to have subsecond precision.
* When testing PURE_PYTHON environments under tox, avoid
poisoning the users global wheel cache.
* Add support for Python 3.5.
* Drop support for Python 2.6 and 3.2.
4.1.1:
* Fix manifest and re-upload to fix stray files included in
4.1.0.
4.1.0:
* Make the Python implementation of Persistent and PickleCache
behave more similarly to the C implementation. In particular,
the Python version can now run the complete ZODB and ZEO test
suites.
* Fix the hashcode of the Python TimeStamp on 32-bit platforms.
- Converted to single-spec
- Dropped fix_32-bit_timestamp_hashcode.patch (fixed upstream)
-------------------------------------------------------------------
Sun May 10 19:46:51 UTC 2015 - benoit.monin@gmx.fr

View File

@ -1,7 +1,7 @@
#
# spec file for package python-persistent
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2013 LISA GmbH, Bingen, Germany.
#
# All modifications and additions to the file contributed by third parties
@ -17,79 +17,80 @@
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-persistent
Version: 4.0.9
Version: 4.2.4.2
Release: 0
Url: https://github.com/zopefoundation/persistent
Summary: Translucent persistent objects
License: ZPL-2.1
Group: Development/Languages/Python
Source: https://pypi.python.org/packages/source/p/persistent/persistent-%{version}.tar.gz
# PATCH-FIX-UPSTREAM fix_32-bit_timestamp_hashcode.patch -- fix timestamp hash computation on 32-bit platform
Patch: fix_32-bit_timestamp_hashcode.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: python-devel
BuildRequires: python-setuptools
BuildRequires: python-zope.interface
Requires: python-zope.interface
Url: https://github.com/zopefoundation/persistent
Source: https://files.pythonhosted.org/packages/source/p/persistent/persistent-%{version}.tar.gz
# Documentation requirements:
BuildRequires: python-Sphinx
BuildRequires: python-repoze.sphinx.autointerface
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitearch: %global python_sitearch %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
%endif
BuildRequires: %{python_module Sphinx}
BuildRequires: %{python_module devel}
BuildRequires: %{python_module repoze.sphinx.autointerface}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module zope.interface}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-zope.interface
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%python_subpackages
%description
This package contains a generic persistence implementation for Python. It forms
the core protocol for making objects interact "transparently" with a database
such as the ZODB.
%package devel
%package devel
Summary: Translucent persistent objects
Group: Development/Languages/Python
Requires: %{name} = %{version}
%description devel
%description devel
This package contains the files needed for binding the %{name} C module.
%package doc
%package doc
Summary: Translucent persistent objects
Group: Development/Languages/Python
Requires: %{name} = %{version}
%description doc
%description doc
This package contains documentation files for %{name}.
%prep
%setup -q -n persistent-%{version}
%patch -p1
rm -rf persistent.egg-info
%build
python setup.py build
python setup.py build_sphinx && rm build/sphinx/html/.buildinfo
%python_build
%{_python_use_flavor python3}
python3 setup.py build_sphinx && rm build/sphinx/html/.buildinfo
%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
%python_install
# don't bother with development files
rm %{buildroot}%python_sitearch/persistent/*.c
%{python_expand rm %{buildroot}%{$python_sitearch}/persistent/*.c
%fdupes -s %{buildroot}%{$python_sitearch}
}
%check
python setup.py -q test
%python_exec setup.py -q test
%files
%files %{python_files}
%defattr(-,root,root,-)
%doc CHANGES.rst COPYRIGHT.txt LICENSE.txt README.rst
%exclude %python_sitearch/persistent/*.h
%python_sitearch/*
%exclude %{python_sitearch}/persistent/*.h
%{python_sitearch}/*
%files devel
%files %{python_files devel}
%defattr(-,root,root,-)
%dir %py_incdir/persistent
%py_incdir/persistent/*.h
%python_sitearch/persistent/*.h
%dir %{python_sysconfig_path include}/persistent
%{python_sysconfig_path include}/persistent/*.h
%{python_sitearch}/persistent/*.h
%files doc
%files %{python_files doc}
%defattr(-,root,root,-)
%doc build/sphinx/html/