* [gentoo-commits] repo/gentoo:master commit in: dev-python/immutables/files/, dev-python/immutables/
@ 2021-08-05 8:56 Michał Górny
0 siblings, 0 replies; 2+ messages in thread
From: Michał Górny @ 2021-08-05 8:56 UTC (permalink / raw
To: gentoo-commits
commit: 2ec357e385f4672bbb6e8966a8f2300a2e6f6fb3
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 5 08:53:36 2021 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Aug 5 08:56:07 2021 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2ec357e3
dev-python/immutables: Backport hash fixes for 32-bit platforms
Closes: https://bugs.gentoo.org/801634
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
.../files/immutables-0.15-32bit-hash.patch | 76 ++++++++++++++++++++++
dev-python/immutables/immutables-0.15-r1.ebuild | 22 +++++++
2 files changed, 98 insertions(+)
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 00000000000..234dfa028c0
--- /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 00000000000..f9ccd8404ee
--- /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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-python/immutables/files/, dev-python/immutables/
@ 2025-03-24 5:42 Michał Górny
0 siblings, 0 replies; 2+ messages in thread
From: Michał Górny @ 2025-03-24 5:42 UTC (permalink / raw
To: gentoo-commits
commit: 6d03e87bef4f431209faa3c094f7fc9f24ce7dc0
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 24 05:37:13 2025 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Mar 24 05:42:30 2025 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6d03e87b
dev-python/immutables: Remove old
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
dev-python/immutables/Manifest | 1 -
.../immutables/files/immutables-0.20-opt-ext.patch | 28 ----------
dev-python/immutables/immutables-0.20.ebuild | 61 ----------------------
3 files changed, 90 deletions(-)
diff --git a/dev-python/immutables/Manifest b/dev-python/immutables/Manifest
index 3bf6c91a9d18..942e39726aec 100644
--- a/dev-python/immutables/Manifest
+++ b/dev-python/immutables/Manifest
@@ -1,2 +1 @@
-DIST immutables-0.20.gh.tar.gz 88169 BLAKE2B fb76793d8d908ea35999a9d3d36cdb6cc2021fda07d0822b23bf1eb7fe02031ac26a7aa3e83e890af24b949eedf6d81089a3670e96f9873a60339d0da44d2484 SHA512 b20a661e4a9161a2fe3db674aac8e84a36dd3e56083e6f6d6b1261a00d38adc136c0a2dce67243a5a4cd5b0568aa48a9d4c758fb27cf74e055f378a501c0f725
DIST immutables-0.21.gh.tar.gz 88188 BLAKE2B be5f5e247f16549b1ccf2fa4a95b81818795d04a0ed934509dc3dcac985be4779ea3c2634cd9e8b57321d58ebf63ce828df08f39f19819e6b537ea3195ae87e3 SHA512 ffd754cd5f13f0d961ec05b1c19df4f9a25c0804a402d0dee91e163531eb9f30b50d8abb1252df775cb83922c69b02baa51bef5d6aa17d80fca57442b93d5e94
diff --git a/dev-python/immutables/files/immutables-0.20-opt-ext.patch b/dev-python/immutables/files/immutables-0.20-opt-ext.patch
deleted file mode 100644
index 6dbcb183a612..000000000000
--- a/dev-python/immutables/files/immutables-0.20-opt-ext.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From b1cb26389d8c8aa646c4debae429fb1515408812 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
-Date: Mon, 13 May 2024 15:51:04 +0200
-Subject: [PATCH] Support disabling C extensions via IMMUTABLES_EXT=0
-
-Support using IMMUTABLES_EXT environment variable to control whether
-the C extension is built explicitly. When set to a value other than 1,
-the extension built is disabled. This is helpful e.g. for future Python
-versions where the extension does not work (this is affecting 3.13 right
-now, but having an explicit option is more future-proof).
----
- setup.py | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/setup.py b/setup.py
-index 8cfc9c97..870de2d1 100644
---- a/setup.py
-+++ b/setup.py
-@@ -27,7 +27,8 @@
- 'unable to read the version from immutables/_version.py')
-
-
--if platform.python_implementation() == 'CPython':
-+if (platform.python_implementation() == 'CPython' and
-+ os.environ.get('IMMUTABLES_EXT', '1') == '1'):
- if os.environ.get("DEBUG_IMMUTABLES") == '1':
- define_macros = []
- undef_macros = ['NDEBUG']
diff --git a/dev-python/immutables/immutables-0.20.ebuild b/dev-python/immutables/immutables-0.20.ebuild
deleted file mode 100644
index 09011a87a8e1..000000000000
--- a/dev-python/immutables/immutables-0.20.ebuild
+++ /dev/null
@@ -1,61 +0,0 @@
-# Copyright 2019-2024 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=8
-
-DISTUTILS_EXT=1
-DISTUTILS_USE_PEP517=setuptools
-PYTHON_COMPAT=( pypy3 python3_{10..13} )
-
-inherit distutils-r1
-
-DESCRIPTION="A high-performance immutable mapping type for Python"
-HOMEPAGE="
- https://github.com/MagicStack/immutables/
- https://pypi.org/project/immutables/
-"
-SRC_URI="
- https://github.com/MagicStack/${PN}/archive/v${PV}.tar.gz
- -> ${P}.gh.tar.gz
-"
-
-LICENSE="Apache-2.0"
-SLOT="0"
-KEYWORDS="~alpha amd64 arm arm64 hppa ~loong ~mips ppc ppc64 ~riscv ~s390 sparc x86"
-IUSE="+native-extensions"
-
-distutils_enable_tests pytest
-
-src_prepare() {
- local PATCHES=(
- # https://github.com/MagicStack/immutables/pull/117
- "${FILESDIR}/${P}-opt-ext.patch"
- )
-
- sed -i -e '/mypy/d' tests/conftest.py || die
- distutils-r1_src_prepare
-}
-
-python_compile() {
- # upstream controls NDEBUG explicitly
- use debug && local -x DEBUG_IMMUTABLES=1
- local -x IMMUTABLES_EXT=$(usex native-extensions 1 0)
- case ${EPYTHON} in
- python3.13)
- # https://github.com/MagicStack/immutables/issues/116
- IMMUTABLES_EXT=0
- ;;
- esac
-
- distutils-r1_python_compile
-}
-
-python_test() {
- local EPYTEST_IGNORE=(
- tests/test_mypy.py
- )
-
- rm -rf immutables || die
- local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
- epytest
-}
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-24 5:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-24 5:42 [gentoo-commits] repo/gentoo:master commit in: dev-python/immutables/files/, dev-python/immutables/ Michał Górny
-- strict thread matches above, loose matches on Subject: below --
2021-08-05 8:56 Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox