summaryrefslogtreecommitdiff
path: root/dev-python/immutables
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2021-08-07 00:16:33 +0100
committerV3n3RiX <venerix@redcorelinux.org>2021-08-07 00:16:33 +0100
commitd162ba1860a88062f4cd61f8b52fc303ba0b2991 (patch)
tree24cd2cf57f3932a24b96e4a0f6666489447e43ba /dev-python/immutables
parent590b9b7b03bf4651e099949e318755af7cfa81b8 (diff)
gentoo resync : 07.08.2021
Diffstat (limited to 'dev-python/immutables')
-rw-r--r--dev-python/immutables/Manifest2
-rw-r--r--dev-python/immutables/files/immutables-0.15-32bit-hash.patch76
-rw-r--r--dev-python/immutables/immutables-0.15-r1.ebuild22
3 files changed, 100 insertions, 0 deletions
diff --git a/dev-python/immutables/Manifest b/dev-python/immutables/Manifest
index 7cc075487403..090cb253d798 100644
--- a/dev-python/immutables/Manifest
+++ b/dev-python/immutables/Manifest
@@ -1,3 +1,5 @@
+AUX immutables-0.15-32bit-hash.patch 2439 BLAKE2B 353f5452dbff85a3b08786174a69068b0a9081ddbc8f88ba03b8c73ba5ab753c2e463cb9ab3af3d61604c23f3b58fe9226efda8119cd1420d3b27871ceb8f1e7 SHA512 add8e68ce6be057889a075c2ba1e58e522ade9e49513118e5e2acfd688b2f1ca20634aee546c0ed5e92181d5c777af4cf312368510c65f8267a465bc90a063b2
DIST immutables-0.15.tar.gz 81297 BLAKE2B cb58142c3b833d529046f09a468b3e3964e3d36e4eaf0825f88b920e6795cd042e2fc837ea6d72000bbc9cbc2fd1de911e08b4f6d189e692748b49e848dfb3fb SHA512 cd0ee20f6d6218eaf13499e40971b6750009ff01a1aefcb7dd45c77ae841296b9d9184013e6e7fe5bdef93587f85cdb8ff459af29424a0077538666260572b8e
+EBUILD immutables-0.15-r1.ebuild 629 BLAKE2B 8b756b31629365c274c51d19894105ee6011724361c2aca1b89fcf6f421e01420f8c5e5b61d6f34d9ef5dadffc99181c3300e22909a0f59fe0e2e6151be06268 SHA512 546fce12a5f41544d94852281d030557f454d13deec05fd070ceb4a15418a1ff8bcbc7373d634c7b10518e3f26e1dd59c661c70f3f16f9ff71091431a7f8f393
EBUILD immutables-0.15.ebuild 487 BLAKE2B 6eb8f45620525e4dd42aea5ae122f9c60e4a1ed5c7585967a7866a71d79fde296565b6e6aa7654f7ca6cc1121cc9ad0ae21a96899c80fa7d3ca2b0c9bef29902 SHA512 1b5e71a31832081a6d6537c8e3084ad29e3492cb2b9042000d6ca488a93a4357bd62c1bf7d4b3023786508604d3750c09cfe54148c0663869e5f607297748a22
MISC metadata.xml 352 BLAKE2B 65ae089f4fcda6735dce5a7772e25b57c69f38e728073213b7c3d1c96382f22cb570fea4890ba1c9086a327b7e24cf1e58514fa6363a1ca595ea9c66cc4a8289 SHA512 96bd2296b24b710cf4a4eecabf3918cc49fb70e859989074d1c07f16b48dca7e2439a4f5f00e5e2283598216fa574621cdb69c78d7a3e7ee9bca144b3955d4d6
diff --git a/dev-python/immutables/files/immutables-0.15-32bit-hash.patch b/dev-python/immutables/files/immutables-0.15-32bit-hash.patch
new file mode 100644
index 000000000000..234dfa028c08
--- /dev/null
+++ b/dev-python/immutables/files/immutables-0.15-32bit-hash.patch
@@ -0,0 +1,76 @@
+From fa355239e70411179c70b16ed4ff7113d8008dad Mon Sep 17 00:00:00 2001
+From: Elvis Pranskevichus <elvis@edgedb.com>
+Date: Wed, 4 Aug 2021 19:25:44 -0700
+Subject: [PATCH] Fix test_none_collisions on 32-bit systems (#69)
+
+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
+---
+ .github/workflows/tests.yml | 10 +++++++++-
+ immutables/map.py | 5 ++++-
+ tests/test_none_keys.py | 14 +++++++++-----
+ 3 files changed, 22 insertions(+), 7 deletions(-)
+
+diff --git a/immutables/map.py b/immutables/map.py
+index 2c1ffa91..0ad28588 100644
+--- a/immutables/map.py
++++ b/immutables/map.py
+@@ -19,7 +19,10 @@
+
+ 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):
+diff --git a/tests/test_none_keys.py b/tests/test_none_keys.py
+index 8c0bb379..26d4220b 100644
+--- 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 @@
+
+ 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):
diff --git a/dev-python/immutables/immutables-0.15-r1.ebuild b/dev-python/immutables/immutables-0.15-r1.ebuild
new file mode 100644
index 000000000000..f9ccd8404ee2
--- /dev/null
+++ b/dev-python/immutables/immutables-0.15-r1.ebuild
@@ -0,0 +1,22 @@
+# Copyright 2019-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{8..10} )
+inherit distutils-r1
+
+DESCRIPTION="A high-performance immutable mapping type for Python"
+HOMEPAGE="https://github.com/MagicStack/immutables"
+SRC_URI="https://github.com/MagicStack/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="Apache-2.0"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~sparc ~x86"
+
+PATCHES=(
+ # https://github.com/MagicStack/immutables/commit/fa355239e70411179c70b16ed4ff7113d8008dad
+ "${FILESDIR}"/${P}-32bit-hash.patch
+)
+
+distutils_enable_tests pytest