Accepting request 958226 from devel:languages:python
Automatic submission by obs-autosubmit OBS-URL: https://build.opensuse.org/request/show/958226 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-immutables?expand=0&rev=8
This commit is contained in:
commit
a6251ed8b1
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3713ab1ebbb6946b7ce1387bb9d1d7f5e09c45add58c2a2ee65f963c171e746b
|
||||
size 44913
|
3
immutables-0.16.tar.gz
Normal file
3
immutables-0.16.tar.gz
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d67e86859598eed0d926562da33325dac7767b7b1eff84e232c22abea19f4360
|
||||
size 84548
|
@ -1,3 +1,14 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Feb 22 09:01:33 UTC 2022 - Dirk Müller <dmueller@suse.com>
|
||||
|
||||
- update to 0.16:
|
||||
* Refactor typings
|
||||
* Update Python 3.10 support, drop Python 3.5
|
||||
* Fix test_none_collisions on 32-bit systems
|
||||
* Clarify the license of the included pythoncapi_compat.h header
|
||||
* Use cibuildwheel to build wheels
|
||||
- drop skip_32bit_tests.patch, test_none_collisions-32-bit.patch (upstream)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Aug 5 06:23:30 UTC 2021 - Matej Cepl <mcepl@suse.com>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package python-immutables
|
||||
#
|
||||
# Copyright (c) 2021 SUSE LLC
|
||||
# Copyright (c) 2022 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -19,16 +19,15 @@
|
||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||
%define skip_python2 1
|
||||
Name: python-immutables
|
||||
Version: 0.15
|
||||
Version: 0.16
|
||||
Release: 0
|
||||
Summary: Immutable collections for Python
|
||||
License: Apache-2.0
|
||||
URL: https://github.com/MagicStack/immutables
|
||||
Source: https://files.pythonhosted.org/packages/source/i/immutables/immutables-%{version}.tar.gz
|
||||
# PATCH-FIX-UPSTREAM test_none_collisions-32-bit.patch gh#MagicStack/immutables#69 mcepl@suse.com
|
||||
# Fix test_none_collisions on 32-bit systems
|
||||
Patch0: test_none_collisions-32-bit.patch
|
||||
BuildRequires: %{python_module devel}
|
||||
BuildRequires: %{python_module mypy}
|
||||
BuildRequires: %{python_module pytest}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
|
@ -1,71 +0,0 @@
|
||||
From a52107d45023a29fe24b97efe849915429e9bb96 Mon Sep 17 00:00:00 2001
|
||||
From: Elvis Pranskevichus <elvis@edgedb.com>
|
||||
Date: Tue, 3 Aug 2021 18:04:22 -0700
|
||||
Subject: [PATCH] Fix test_none_collisions on 32-bit systems
|
||||
|
||||
There are two issues at play here:
|
||||
|
||||
1. Python version of `map_hash` unnecessarily performs hash truncation
|
||||
even if the hash is already 32-bit wide, which potentially converts
|
||||
it from signed int to unsigned long.
|
||||
|
||||
2. The `test_none_collisions` test generates a collision node with
|
||||
hash greater than 2^32.
|
||||
|
||||
Both of these are problematic on 32-bit systems, where `sizeof(Py_hash_t)`
|
||||
is 4, and so anything that doesn't fit into `Py_hash_t` gets bit-mangled,
|
||||
breaking the `hash(x) != x` invariance that the test relies upon.
|
||||
|
||||
Fixes: #53
|
||||
Fixes: #50
|
||||
---
|
||||
immutables/map.py | 5 ++++-
|
||||
tests/test_none_keys.py | 14 +++++++++-----
|
||||
2 files changed, 13 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/immutables/map.py
|
||||
+++ b/immutables/map.py
|
||||
@@ -19,7 +19,10 @@ _mut_id = itertools.count(1).__next__
|
||||
|
||||
def map_hash(o):
|
||||
x = hash(o)
|
||||
- return (x & 0xffffffff) ^ ((x >> 32) & 0xffffffff)
|
||||
+ if sys.hash_info.width > 32:
|
||||
+ return (x & 0xffffffff) ^ ((x >> 32) & 0xffffffff)
|
||||
+ else:
|
||||
+ return x
|
||||
|
||||
|
||||
def map_mask(hash, shift):
|
||||
--- a/tests/test_none_keys.py
|
||||
+++ b/tests/test_none_keys.py
|
||||
@@ -1,3 +1,4 @@
|
||||
+import ctypes
|
||||
import unittest
|
||||
|
||||
from immutables.map import map_hash, map_mask, Map as PyMap
|
||||
@@ -6,16 +7,19 @@ from immutables._testutils import HashKe
|
||||
|
||||
none_hash = map_hash(None)
|
||||
assert(none_hash != 1)
|
||||
-assert((none_hash >> 32) == 0)
|
||||
+assert(none_hash.bit_length() <= 32)
|
||||
|
||||
-not_collision = 0xffffffff & (~none_hash)
|
||||
+none_hash_u = ctypes.c_size_t(none_hash).value
|
||||
+not_collision = 0xffffffff & (~none_hash_u)
|
||||
|
||||
mask = 0x7ffffffff
|
||||
-none_collisions = [none_hash & (mask >> shift)
|
||||
+none_collisions = [none_hash_u & (mask >> shift)
|
||||
for shift in reversed(range(0, 32, 5))]
|
||||
assert(len(none_collisions) == 7)
|
||||
-none_collisions = [h | (not_collision & (mask << shift))
|
||||
- for shift, h in zip(range(5, 37, 5), none_collisions)]
|
||||
+none_collisions = [
|
||||
+ ctypes.c_ssize_t(h | (not_collision & (mask << shift))).value
|
||||
+ for shift, h in zip(range(5, 37, 5), none_collisions)
|
||||
+]
|
||||
|
||||
|
||||
class NoneCollision(HashKey):
|
Loading…
Reference in New Issue
Block a user