From ee40a4c5dfc492420de9975b502ac87a7142a3d5 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 17 Dec 2021 15:06:30 -0800 Subject: [PATCH 1/7] build/pkgs/python3: Update to 3.10.1 --- build/pkgs/python3/checksums.ini | 6 +++--- build/pkgs/python3/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/python3/checksums.ini b/build/pkgs/python3/checksums.ini index 769c1cabe8b..934a64c1b5f 100644 --- a/build/pkgs/python3/checksums.ini +++ b/build/pkgs/python3/checksums.ini @@ -1,5 +1,5 @@ tarball=Python-VERSION.tar.xz -sha1=6274e5631c520d75bf1f0a046640fd3996fe99f0 -md5=11d12076311563252a995201248d17e5 -cksum=2273440860 +sha1=1a534e99b95db0d30dacc8f10418cc5758b04df7 +md5=789210934745a65247a3ebf5da9adb64 +cksum=3627214001 upstream_url=https://www.python.org/ftp/python/VERSION/Python-VERSION.tar.xz diff --git a/build/pkgs/python3/package-version.txt b/build/pkgs/python3/package-version.txt index b04bfd83847..f870be23bad 100644 --- a/build/pkgs/python3/package-version.txt +++ b/build/pkgs/python3/package-version.txt @@ -1 +1 @@ -3.9.9 +3.10.1 From 50851edb5df9292bbef51353740a2799b46a78a8 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 24 May 2021 16:20:34 -0700 Subject: [PATCH 2/7] build/pkgs/python3/patches/cygwin-readline.patch: Remove --- .../python3/patches/cygwin-readline.patch | 31 ------------------- 1 file changed, 31 deletions(-) delete mode 100644 build/pkgs/python3/patches/cygwin-readline.patch diff --git a/build/pkgs/python3/patches/cygwin-readline.patch b/build/pkgs/python3/patches/cygwin-readline.patch deleted file mode 100644 index 9952ca74a72..00000000000 --- a/build/pkgs/python3/patches/cygwin-readline.patch +++ /dev/null @@ -1,31 +0,0 @@ -Some patches to prevent an error that would occur on Cygwin trying to call -`ldd` on the .dll.a import library for readline, which doesn't work (we -might consider later updating this with a call to dlltool instead, which is -the appropriate alternative). - -Also adds the correct link flags for curses on Cygwin. - -diff --git a/setup.py b/setup.py -index 598f581..2405f17 100644 ---- a/setup.py -+++ b/setup.py -@@ -880,7 +880,8 @@ class PyBuildExt(build_ext): - if not os.path.exists(self.build_temp): - os.makedirs(self.build_temp) - # Determine if readline is already linked against curses or tinfo. -- if do_readline: -+ # This doesn't work properly on Cygwin -+ if do_readline and HOST_PLATFORM != 'cygwin': - if CROSS_COMPILING: - ret = os.system("%s -d %s | grep '(NEEDED)' > %s" \ - % (sysconfig.get_config_var('READELF'), -@@ -982,6 +983,9 @@ class PyBuildExt(build_ext): - curses_enabled = True - if curses_library.startswith('ncurses'): - curses_libs = [curses_library] -+ if HOST_PLATFORM == 'cygwin': -+ curses_libs.append('tinfo' + -+ 'w' if curses_library[-1] == 'w' else '') - self.add(Extension('_curses', ['_cursesmodule.c'], - include_dirs=curses_includes, - define_macros=curses_defines, From 3db6ad20cfbae3b9fbc15b2dd6c3fea88d6d5130 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 17 Dec 2021 15:11:55 -0800 Subject: [PATCH 3/7] build/pkgs/python3: Add https://github.com/python/cpython/pull/30005 --- build/pkgs/python3/patches/30005.patch | 71 ++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 build/pkgs/python3/patches/30005.patch diff --git a/build/pkgs/python3/patches/30005.patch b/build/pkgs/python3/patches/30005.patch new file mode 100644 index 00000000000..8fa7a8a543c --- /dev/null +++ b/build/pkgs/python3/patches/30005.patch @@ -0,0 +1,71 @@ +From fa787ef1e88965aedd927258ae8aad59fd81abc7 Mon Sep 17 00:00:00 2001 +From: Pablo Galindo Salgado +Date: Thu, 9 Dec 2021 13:53:44 +0000 +Subject: [PATCH] bpo-46025: Fix a crash in the atexit module for + auto-unregistering functions (GH-30002) (cherry picked from commit + f0d290d25cad66e615ada68ba190b8a23ac1deaa) + +Co-authored-by: Pablo Galindo Salgado +--- + Lib/test/_test_atexit.py | 15 +++++++++++++++ + .../2021-12-09-11-41-35.bpo-46025.pkEvW9.rst | 2 ++ + Modules/atexitmodule.c | 5 ++++- + 3 files changed, 21 insertions(+), 1 deletion(-) + create mode 100644 Misc/NEWS.d/next/Core and Builtins/2021-12-09-11-41-35.bpo-46025.pkEvW9.rst + +diff --git a/Lib/test/_test_atexit.py b/Lib/test/_test_atexit.py +index a31658531113b..55d2808334917 100644 +--- a/Lib/test/_test_atexit.py ++++ b/Lib/test/_test_atexit.py +@@ -116,6 +116,21 @@ def test_bound_methods(self): + atexit._run_exitfuncs() + self.assertEqual(l, [5]) + ++ def test_atexit_with_unregistered_function(self): ++ # See bpo-46025 for more info ++ def func(): ++ atexit.unregister(func) ++ 1/0 ++ atexit.register(func) ++ try: ++ with support.catch_unraisable_exception() as cm: ++ atexit._run_exitfuncs() ++ self.assertEqual(cm.unraisable.object, func) ++ self.assertEqual(cm.unraisable.exc_type, ZeroDivisionError) ++ self.assertEqual(type(cm.unraisable.exc_value), ZeroDivisionError) ++ finally: ++ atexit.unregister(func) ++ + + if __name__ == "__main__": + unittest.main() +diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-12-09-11-41-35.bpo-46025.pkEvW9.rst b/Misc/NEWS.d/next/Core and Builtins/2021-12-09-11-41-35.bpo-46025.pkEvW9.rst +new file mode 100644 +index 0000000000000..dd2f1ff4731e7 +--- /dev/null ++++ b/Misc/NEWS.d/next/Core and Builtins/2021-12-09-11-41-35.bpo-46025.pkEvW9.rst +@@ -0,0 +1,2 @@ ++Fix a crash in the :mod:`atexit` module involving functions that unregister ++themselves before raising exceptions. Patch by Pablo Galindo. +diff --git a/Modules/atexitmodule.c b/Modules/atexitmodule.c +index e536b4abe295f..95c653cf4782a 100644 +--- a/Modules/atexitmodule.c ++++ b/Modules/atexitmodule.c +@@ -93,13 +93,16 @@ atexit_callfuncs(struct atexit_state *state) + continue; + } + ++ // bpo-46025: Increment the refcount of cb->func as the call itself may unregister it ++ PyObject* the_func = Py_NewRef(cb->func); + PyObject *res = PyObject_Call(cb->func, cb->args, cb->kwargs); + if (res == NULL) { +- _PyErr_WriteUnraisableMsg("in atexit callback", cb->func); ++ _PyErr_WriteUnraisableMsg("in atexit callback", the_func); + } + else { + Py_DECREF(res); + } ++ Py_DECREF(the_func); + } + + atexit_cleanup(state); From 64dbefd12fd070778592694c5a3408560b96b826 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 30 Jan 2022 15:30:23 -0800 Subject: [PATCH 4/7] build/pkgs/python3: Update ro 3.10.2 --- build/pkgs/python3/checksums.ini | 6 +++--- build/pkgs/python3/package-version.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/pkgs/python3/checksums.ini b/build/pkgs/python3/checksums.ini index 934a64c1b5f..b57e3095c55 100644 --- a/build/pkgs/python3/checksums.ini +++ b/build/pkgs/python3/checksums.ini @@ -1,5 +1,5 @@ tarball=Python-VERSION.tar.xz -sha1=1a534e99b95db0d30dacc8f10418cc5758b04df7 -md5=789210934745a65247a3ebf5da9adb64 -cksum=3627214001 +sha1=e618946549cca1eb0d6d4cdf516003fec3975003 +md5=14e8c22458ed7779a1957b26cde01db9 +cksum=1118621485 upstream_url=https://www.python.org/ftp/python/VERSION/Python-VERSION.tar.xz diff --git a/build/pkgs/python3/package-version.txt b/build/pkgs/python3/package-version.txt index f870be23bad..7b59a5caab6 100644 --- a/build/pkgs/python3/package-version.txt +++ b/build/pkgs/python3/package-version.txt @@ -1 +1 @@ -3.10.1 +3.10.2 From f34ae90c97ea30e539a2ece5cb664a5ca9d20b79 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 30 Jan 2022 16:28:06 -0800 Subject: [PATCH 5/7] build/pkgs/python3/patches/30005.patch: Remove --- build/pkgs/python3/patches/30005.patch | 71 -------------------------- 1 file changed, 71 deletions(-) delete mode 100644 build/pkgs/python3/patches/30005.patch diff --git a/build/pkgs/python3/patches/30005.patch b/build/pkgs/python3/patches/30005.patch deleted file mode 100644 index 8fa7a8a543c..00000000000 --- a/build/pkgs/python3/patches/30005.patch +++ /dev/null @@ -1,71 +0,0 @@ -From fa787ef1e88965aedd927258ae8aad59fd81abc7 Mon Sep 17 00:00:00 2001 -From: Pablo Galindo Salgado -Date: Thu, 9 Dec 2021 13:53:44 +0000 -Subject: [PATCH] bpo-46025: Fix a crash in the atexit module for - auto-unregistering functions (GH-30002) (cherry picked from commit - f0d290d25cad66e615ada68ba190b8a23ac1deaa) - -Co-authored-by: Pablo Galindo Salgado ---- - Lib/test/_test_atexit.py | 15 +++++++++++++++ - .../2021-12-09-11-41-35.bpo-46025.pkEvW9.rst | 2 ++ - Modules/atexitmodule.c | 5 ++++- - 3 files changed, 21 insertions(+), 1 deletion(-) - create mode 100644 Misc/NEWS.d/next/Core and Builtins/2021-12-09-11-41-35.bpo-46025.pkEvW9.rst - -diff --git a/Lib/test/_test_atexit.py b/Lib/test/_test_atexit.py -index a31658531113b..55d2808334917 100644 ---- a/Lib/test/_test_atexit.py -+++ b/Lib/test/_test_atexit.py -@@ -116,6 +116,21 @@ def test_bound_methods(self): - atexit._run_exitfuncs() - self.assertEqual(l, [5]) - -+ def test_atexit_with_unregistered_function(self): -+ # See bpo-46025 for more info -+ def func(): -+ atexit.unregister(func) -+ 1/0 -+ atexit.register(func) -+ try: -+ with support.catch_unraisable_exception() as cm: -+ atexit._run_exitfuncs() -+ self.assertEqual(cm.unraisable.object, func) -+ self.assertEqual(cm.unraisable.exc_type, ZeroDivisionError) -+ self.assertEqual(type(cm.unraisable.exc_value), ZeroDivisionError) -+ finally: -+ atexit.unregister(func) -+ - - if __name__ == "__main__": - unittest.main() -diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-12-09-11-41-35.bpo-46025.pkEvW9.rst b/Misc/NEWS.d/next/Core and Builtins/2021-12-09-11-41-35.bpo-46025.pkEvW9.rst -new file mode 100644 -index 0000000000000..dd2f1ff4731e7 ---- /dev/null -+++ b/Misc/NEWS.d/next/Core and Builtins/2021-12-09-11-41-35.bpo-46025.pkEvW9.rst -@@ -0,0 +1,2 @@ -+Fix a crash in the :mod:`atexit` module involving functions that unregister -+themselves before raising exceptions. Patch by Pablo Galindo. -diff --git a/Modules/atexitmodule.c b/Modules/atexitmodule.c -index e536b4abe295f..95c653cf4782a 100644 ---- a/Modules/atexitmodule.c -+++ b/Modules/atexitmodule.c -@@ -93,13 +93,16 @@ atexit_callfuncs(struct atexit_state *state) - continue; - } - -+ // bpo-46025: Increment the refcount of cb->func as the call itself may unregister it -+ PyObject* the_func = Py_NewRef(cb->func); - PyObject *res = PyObject_Call(cb->func, cb->args, cb->kwargs); - if (res == NULL) { -- _PyErr_WriteUnraisableMsg("in atexit callback", cb->func); -+ _PyErr_WriteUnraisableMsg("in atexit callback", the_func); - } - else { - Py_DECREF(res); - } -+ Py_DECREF(the_func); - } - - atexit_cleanup(state); From 18668faee6026202cf44409ca0323b7e6070ed1f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 14 Feb 2022 21:49:42 -0800 Subject: [PATCH 6/7] build/pkgs/python3/spkg-configure.m4: No longer flag system python 3.10 as experimental --- build/pkgs/python3/spkg-configure.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/python3/spkg-configure.m4 b/build/pkgs/python3/spkg-configure.m4 index 5e3481a6ee1..27af5be576d 100644 --- a/build/pkgs/python3/spkg-configure.m4 +++ b/build/pkgs/python3/spkg-configure.m4 @@ -1,7 +1,7 @@ SAGE_SPKG_CONFIGURE([python3], [ m4_pushdef([MIN_VERSION], [3.7.0]) m4_pushdef([MIN_NONDEPRECATED_VERSION], [3.7.0]) - m4_pushdef([LT_STABLE_VERSION], [3.10.0]) + m4_pushdef([LT_STABLE_VERSION], [3.11.0]) m4_pushdef([LT_VERSION], [3.11.0]) AC_ARG_WITH([python], [AS_HELP_STRING([--with-python=PYTHON3], From 95e378446c7d4622e6c4ea86271335abea8c5aa2 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 3 Mar 2022 12:22:46 -0800 Subject: [PATCH 7/7] build/pkgs/python3/patches/0001-bpo-22699-Allow-compiling-on-debian-ubuntu-with-a-di.patch: Update from https://github.com/conda-forge/python-feedstock/blob/master/recipe/patches/0008-bpo-22699-Allow-compiling-on-debian-ubuntu-with-a-di.patch --- ...llow-compiling-on-debian-ubuntu-with-a-di.patch | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build/pkgs/python3/patches/0001-bpo-22699-Allow-compiling-on-debian-ubuntu-with-a-di.patch b/build/pkgs/python3/patches/0001-bpo-22699-Allow-compiling-on-debian-ubuntu-with-a-di.patch index 02471f67430..ec3d84c8499 100644 --- a/build/pkgs/python3/patches/0001-bpo-22699-Allow-compiling-on-debian-ubuntu-with-a-di.patch +++ b/build/pkgs/python3/patches/0001-bpo-22699-Allow-compiling-on-debian-ubuntu-with-a-di.patch @@ -12,20 +12,20 @@ patch than given 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py -index 8fb8ea5c47..783d20bdcd 100644 +index 554699608d..d5bbeb90d5 100644 --- a/setup.py +++ b/setup.py -@@ -663,9 +663,30 @@ def add_multiarch_paths(self): +@@ -667,9 +667,30 @@ def check_extension_import(self, ext): + def add_multiarch_paths(self): # Debian/Ubuntu multiarch support. # https://wiki.ubuntu.com/MultiarchSpec - cc = sysconfig.get_config_var('CC') - tmpfile = os.path.join(self.build_temp, 'multiarch') if not os.path.exists(self.build_temp): os.makedirs(self.build_temp) + + tmpfile_sysroot = os.path.join(self.build_temp, 'sysroot') + ret_sysroot = run_command( -+ '%s -print-sysroot > %s 2> /dev/null' % (cc, tmpfile_sysroot)) ++ '%s -print-sysroot > %s 2> /dev/null' % (CC, tmpfile_sysroot)) + + try: + if ret_sysroot == 0: @@ -35,9 +35,9 @@ index 8fb8ea5c47..783d20bdcd 100644 + # the compiler from debian/ubuntu + if sysroot not in ['', '/']: + add_dir_to_list(self.compiler.library_dirs, -+ sysroot + '/usr/lib') ++ sysroot + '/usr/lib/') + add_dir_to_list(self.compiler.include_dirs, -+ sysroot + '/usr/include') ++ sysroot + '/usr/include/') + return + finally: + os.unlink(tmpfile_sysroot) @@ -45,7 +45,7 @@ index 8fb8ea5c47..783d20bdcd 100644 + tmpfile = os.path.join(self.build_temp, 'multiarch') + ret = run_command( - '%s -print-multiarch > %s 2> /dev/null' % (cc, tmpfile)) + '%s -print-multiarch > %s 2> /dev/null' % (CC, tmpfile)) multiarch_path_component = '' --- a/setup.py 2021-09-28 23:49:53.193868987 -0700 +++ b/setup.py 2021-09-28 23:50:13.554098642 -0700