From 2b315fe020ab47acb0835aa6395d3e31d43756b2 Mon Sep 17 00:00:00 2001 From: itd Date: Sun, 13 Mar 2022 21:08:03 +0100 Subject: gnu: python-mypy: Fix test errors on i686-linux. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/packages/patches/python-mypy-12332.patch: New patch. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/python-check.scm (python-mypy)[source]: Use patch "python-mypy-12332.patch" to avoid overflow issues resulting in test failures. Signed-off-by: Ludovic Courtès --- gnu/local.mk | 1 + gnu/packages/patches/python-mypy-12332.patch | 68 ++++++++++++++++++++++++++++ gnu/packages/python-check.scm | 4 +- 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/python-mypy-12332.patch (limited to 'gnu') diff --git a/gnu/local.mk b/gnu/local.mk index 4649ec6cd9..423feb2028 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1717,6 +1717,7 @@ dist_patch_DATA = \ %D%/packages/patches/python-versioneer-guix-support.patch \ %D%/packages/patches/python-waitress-fix-tests.patch \ %D%/packages/patches/python-werkzeug-tests.patch \ + %D%/packages/patches/python-mypy-12332.patch \ %D%/packages/patches/qemu-build-info-manual.patch \ %D%/packages/patches/qemu-glibc-2.27.patch \ %D%/packages/patches/qemu-glibc-2.30.patch \ diff --git a/gnu/packages/patches/python-mypy-12332.patch b/gnu/packages/patches/python-mypy-12332.patch new file mode 100644 index 0000000000..d43cf42ed1 --- /dev/null +++ b/gnu/packages/patches/python-mypy-12332.patch @@ -0,0 +1,68 @@ +From 518c864805dd93e62d59439e665a0ce9d6778419 Mon Sep 17 00:00:00 2001 +From: Ekin Dursun +Date: Thu, 10 Mar 2022 22:06:48 +0300 +Subject: [PATCH] mypyc: Fix overflow in id function (CPyTagged_Id) + +In CPython, the id of an object is its address. It's computed by +converting the pointer to an unsigned integer (PyLong_FromVoidPtr). A +similar logic is present here, pointer is converted to a Py_ssize_t and +CPyTagged_FromSsize_t is called with that integer. + +There is a problem with that approach: Py_ssize_t cannot hold every +pointer value. Sometimes overflow happens and CPyTagged_FromSsize_t is +called with a negative integer. + +With the new approach, the number is checked: If it fits in a +Py_ssize_t, CPyTagged_FromSsize_t is called. If not, it is directly +converted to a PyObject using PyLong_FromVoidPtr. +--- + mypyc/lib-rt/CPy.h | 1 + + mypyc/lib-rt/int_ops.c | 9 +++++++++ + mypyc/lib-rt/misc_ops.c | 2 +- + 3 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/mypyc/lib-rt/CPy.h b/mypyc/lib-rt/CPy.h +index 987819154ab..9f5ae52d4e4 100644 +--- a/mypyc/lib-rt/CPy.h ++++ b/mypyc/lib-rt/CPy.h +@@ -121,6 +121,7 @@ static inline size_t CPy_FindAttrOffset(PyTypeObject *trait, CPyVTableItem *vtab + + + CPyTagged CPyTagged_FromSsize_t(Py_ssize_t value); ++CPyTagged CPyTagged_FromVoidPtr(void *ptr); + CPyTagged CPyTagged_FromObject(PyObject *object); + CPyTagged CPyTagged_StealFromObject(PyObject *object); + CPyTagged CPyTagged_BorrowFromObject(PyObject *object); +diff --git a/mypyc/lib-rt/int_ops.c b/mypyc/lib-rt/int_ops.c +index 1275f2c1057..edf06314161 100644 +--- a/mypyc/lib-rt/int_ops.c ++++ b/mypyc/lib-rt/int_ops.c +@@ -26,6 +26,15 @@ CPyTagged CPyTagged_FromSsize_t(Py_ssize_t value) { + } + } + ++CPyTagged CPyTagged_FromVoidPtr(void *ptr) { ++ if ((uintptr_t)ptr > PY_SSIZE_T_MAX) { ++ PyObject *object = PyLong_FromVoidPtr(ptr); ++ return ((CPyTagged)object) | CPY_INT_TAG; ++ } else { ++ return CPyTagged_FromSsize_t((Py_ssize_t)ptr); ++ } ++} ++ + CPyTagged CPyTagged_FromObject(PyObject *object) { + int overflow; + // The overflow check knows about CPyTagged's width +diff --git a/mypyc/lib-rt/misc_ops.c b/mypyc/lib-rt/misc_ops.c +index cebd1cf997f..dcce89d9072 100644 +--- a/mypyc/lib-rt/misc_ops.c ++++ b/mypyc/lib-rt/misc_ops.c +@@ -437,7 +437,7 @@ CPyPickle_GetState(PyObject *obj) + } + + CPyTagged CPyTagged_Id(PyObject *o) { +- return CPyTagged_FromSsize_t((Py_ssize_t)o); ++ return CPyTagged_FromVoidPtr(o); + } + + #define MAX_INT_CHARS 22 diff --git a/gnu/packages/python-check.scm b/gnu/packages/python-check.scm index 05a378601f..5bbe544113 100644 --- a/gnu/packages/python-check.scm +++ b/gnu/packages/python-check.scm @@ -1658,7 +1658,9 @@ supported by the MyPy typechecker.") (file-name (git-file-name name version)) (sha256 (base32 - "1v83flrdxh8grcp40qw04q4hzjflih9xwib64078vsxv2w36f817")))) + "1v83flrdxh8grcp40qw04q4hzjflih9xwib64078vsxv2w36f817")) + (patches + (search-patches "python-mypy-12332.patch")))) (build-system python-build-system) (arguments `(#:phases -- cgit v1.2.3 01-11shell: Cache profiles even when using package specs....This enables profile caching not just when '-m' or '-f' is used, but also when package specs are passed on the command line, as in: guix shell -D guix git It also changes profile cache keys to include the system type, which was previously ignored. * guix/scripts/shell.scm (options-with-caching)[single-file-for-caching]: Remove. Call 'profile-cached-gc-root' instead; adjust to accept two values. (profile-cache-primary-key): New procedure. (profile-cache-key): Remove. (profile-file-cache-key, profile-spec-cache-key): New procedures. (profile-cached-gc-root): Rewrite to include functionality formally in 'single-file-for-caching', but extend to handle package specs. * gnu/packages.scm (cache-is-authoritative?): Export. * guix/transformations.scm (transformation-option-key?): New procedure. * doc/guix.texi (Invoking guix shell): Move '--rebuild-cache' documentation to the bottom, just above '--root'. Explain caching and how these two options relate to that. Ludovic Courtès 2020-07-30packages: 'generate-package-cache' is deterministic....Fixes <https://bugs.gnu.org/42009>. Reported by Marinus <marinus.savoritias@disroot.org>. * gnu/packages.scm (generate-package-cache)[entry-key, entry<?] [variables]: New variables. [expand-cache]: Change to take two arguments. [exp]: Fold over VARIABLES. Ludovic Courtès 2020-07-25Use 'formatted-message' instead of '&message' where appropriate....* gnu.scm (%try-use-modules): Use 'formatted-message' instead of '&message'. * gnu/machine/digital-ocean.scm (maybe-raise-unsupported-configuration-error): Likewise. * gnu/machine/ssh.scm (machine-check-file-system-availability): Likewise. (machine-check-building-for-appropriate-system): Likewise. (deploy-managed-host): Likewise. (maybe-raise-unsupported-configuration-error): Likewise. * gnu/packages.scm (search-patch): Likewise. * gnu/services.scm (%service-with-default-value): Likewise. (files->etc-directory): Likewise. (fold-services): Likewise. * gnu/system.scm (locale-name->definition*): Likewise. * gnu/system/mapped-devices.scm (check-device-initrd-modules): Likewise. (check-luks-device): Likewise. * guix/channels.scm (latest-channel-instance): Likewise. * guix/cve.scm (json->cve-items): Likewise. * guix/git-authenticate.scm (commit-signing-key): Likewise. (commit-authorized-keys): Likewise. (authenticate-commit): Likewise. (verify-introductory-commit): Likewise. * guix/remote.scm (remote-pipe-for-gexp): Likewise. * guix/scripts/graph.scm (assert-package): Likewise. * guix/scripts/offload.scm (private-key-from-file*): Likewise. * guix/ssh.scm (authenticate-server*): Likewise. (open-ssh-session): Likewise. (remote-inferior): Likewise. * guix/ui.scm (matching-generations): Likewise. * guix/upstream.scm (package-update): Likewise. * tests/channels.scm ("latest-channel-instances, missing introduction for 'guix'"): Catch 'formatted-message?'. ("authenticate-channel, wrong first commit signer"): Likewise. * tests/lint.scm ("patches: not found"): Adjust message string. * tests/packages.scm ("patch not found yields a run-time error"): Catch 'formatted-message?'. * guix/lint.scm (check-patch-file-names): Handle 'formatted-message?'. (check-derivation): Ditto. Ludovic Courtès 2020-01-17packages: Prevent inlining of 'find-best-packages-by-name'....This allows 'tests/packages.scm' to mock it. * gnu/packages.scm (find-best-packages-by-name): Set! it at the top level to prevent it from being inline on Guile 3. Ludovic Courtès 2020-01-06Adjust module autoloads....In Guile < 2.9.7, autoloading a module would give you access to all its bindings. In future versions, autoloading a module gives access only to the listed bindings, as per #:select (see <https://bugs.gnu.org/38895>). This commit adjusts autoloads to the new semantics, allowing Guix to be built with Guile 2.9.7/2.9.8. * guix/build/download.scm <top level>: Remove call to 'module-autoload!'. (load-gnutls): New procedure. (tls-wrap): Call it. * guix/git.scm <top level>: Remove call to 'module-autoload!'. (load-git-submodules): New procedure. (update-submodules): Call it instead of 'resolve-interface'. * gnu/bootloader/grub.scm: Replace #:autoload with #:use-module. * gnu/packages.scm: Likewise. * gnu/packages/ssh.scm: Likewise. * gnu/packages/tex.scm: Likewise. * gnu/services/cuirass.scm: Likewise. * gnu/services/mcron.scm: Likewise. * guix/lint.scm: Augment list of bindings in #:autoload. * guix/scripts/build.scm: Likewise. * guix/scripts/gc.scm: Likewise. * guix/scripts/pack.scm: Likewise. * guix/scripts/publish.scm: Likewise. * guix/scripts/pull.scm: Likewise. * guix/utils.scm: Remove unnecessary #:autoload clauses; replace one of them with #:use-module. Ludovic Courtès