aboutsummaryrefslogtreecommitdiffstats
path: root/main/python3
diff options
context:
space:
mode:
Diffstat (limited to 'main/python3')
-rw-r--r--main/python3/APKBUILD56
-rw-r--r--main/python3/bpo-43112.patch211
-rw-r--r--main/python3/custom-bluetooth-h-path.patch25
-rw-r--r--main/python3/ece5dfd403dac211f8d3c72701fe7ba7b7aa5b5f.patch186
-rw-r--r--main/python3/fix-xattrs-glibc.patch10
-rw-r--r--main/python3/test_nntplib.patch34
6 files changed, 262 insertions, 260 deletions
diff --git a/main/python3/APKBUILD b/main/python3/APKBUILD
index 3e5f286189..0f44ba96ef 100644
--- a/main/python3/APKBUILD
+++ b/main/python3/APKBUILD
@@ -1,21 +1,20 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
-# Contributor: Kiyoshi Aman <kiyoshi.aman@gmail.com>
+# Contributor: Sheila Aman <sheila@vulpine.house>
pkgname=python3
# the python3-tkinter's pkgver needs to be synchronized with this.
-pkgver=3.8.7
-_bluez_ver=5.54
+pkgver=3.9.6
+_bluez_ver=5.55
_basever="${pkgver%.*}"
-pkgrel=3
+pkgrel=0
pkgdesc="A high-level scripting language"
url="https://www.python.org/"
arch="all"
license="PSF-2.0"
-subpackages="$pkgname-dbg $pkgname-dev $pkgname-doc $pkgname-tests::noarch
- $pkgname-wininst"
+subpackages="$pkgname-dbg $pkgname-dev $pkgname-doc $pkgname-tests::noarch"
makedepends="expat-dev openssl-dev zlib-dev ncurses-dev bzip2-dev xz-dev
sqlite-dev libffi-dev tcl-dev linux-headers gdbm-dev>=1.18.1-r0 readline-dev
- mpdecimal-dev automake autoconf libtool !gettext-dev"
+ mpdecimal-dev automake autoconf libtool autoconf-archive !gettext-dev"
source="https://www.python.org/ftp/python/$pkgver/Python-$pkgver.tar.xz
https://www.kernel.org/pub/linux/bluetooth/bluez-$_bluez_ver.tar.xz
fix-xattrs-glibc.patch
@@ -23,12 +22,14 @@ source="https://www.python.org/ftp/python/$pkgver/Python-$pkgver.tar.xz
custom-bluetooth-h-path.patch
arm-alignment.patch
mpdecimal-2.5.1.patch
- test_nntplib.patch
- ece5dfd403dac211f8d3c72701fe7ba7b7aa5b5f.patch
+ bpo-43112.patch
"
+options="net" # Required for tests
builddir="$srcdir/Python-$pkgver"
# secfixes:
+# 3.8.8-r0:
+# - CVE-2021-23336
# 3.8.7-r2:
# - CVE-2021-3177
# 3.8.5-r0:
@@ -54,6 +55,9 @@ prepare() {
mv "$srcdir"/bluez-$_bluez_ver/lib "$srcdir"/bluez-$_bluez_ver/bluetooth
+ # Speed up LTO
+ sed -i -e "s|-flto |-flto=4 |g" configure configure.ac
+
autoreconf -fi
sed "s|@bluetoothdir@|\"$srcdir/bluez-$_bluez_ver\"|g" -i setup.py
@@ -68,8 +72,9 @@ build() {
# link against bluez. Depending on bluez-dev introduces a circular dep:
# Python -> bluez -> glib -> meson -> python
./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
--prefix=/usr \
- --disable-rpath \
--enable-ipv6 \
--enable-loadable-sqlite-extensions \
--enable-optimizations \
@@ -80,13 +85,17 @@ build() {
--with-system-expat \
--with-system-ffi \
--with-system-libmpdec \
- --with-threads \
--without-ensurepip \
--with-bluetoothdir="$srcdir/bluez-$_bluez_ver"
# set thread stack size to 1MB so we don't segfault before we hit
# sys.getrecursionlimit()
- make EXTRA_CFLAGS="$CFLAGS -DTHREAD_STACK_SIZE=0x100000"
+ # s390x needs more stack space due to its calling convention
+ local stacksize=0x100000
+ case "$CARCH" in
+ s390x) stacksize=0x200000;;
+ esac
+ make EXTRA_CFLAGS="$CFLAGS -DTHREAD_STACK_SIZE=$stacksize"
}
check() {
@@ -129,6 +138,9 @@ EOF
fail="$fail test_multiprocessing_main_handling" # fails on x86_64
fail="$fail test_runpy" # fails on x86_64
fail="$fail test_threading" # hangs on all arches (except x86_64?)
+ fail="$fail test_selectors" # AssertionError: 'Python' not found in '' (python3.9)
+ fail="$fail test_nntplib"
+ fail="$fail test_asyncio" # hangs; routinely problematic (e.g. bpo-39101, bpo-41891, bpo-42183)
# kernel related
fail="$fail test_fcntl" # wants DNOTIFY, we don't have it
@@ -181,19 +193,13 @@ tests() {
"$subpkgdir"/usr/lib/python$_basever/
}
-wininst() {
- pkgdesc="Python wininst files"
- mkdir -p "$subpkgdir"/usr/lib/python$_basever/distutils/command
- mv "$pkgdir"/usr/lib/python$_basever/distutils/command/*.exe \
- "$subpkgdir"/usr/lib/python$_basever/distutils/command
-}
-
-sha512sums="6a27d8eab3076930df46b0cf127f9b664f8d4147349b2b98132f464deb7f69d87e0167e8ee8e6c64249125ad73760d965ecbc81c252b63a1e7aac95594c62b74 Python-3.8.7.tar.xz
-e19d15d3a478a7af47c1921c8827843492e38787b1182152155bd3d8ad9e1d8ee25c5fda1f24e38c54ebbf946b09fe75007dca9a24d1c35f73303558e558dcbe bluez-5.54.tar.xz
-37b6ee5d0d5de43799316aa111423ba5a666c17dc7f81b04c330f59c1d1565540eac4c585abe2199bbed52ebe7426001edb1c53bd0a17486a2a8e052d0f494ad fix-xattrs-glibc.patch
+sha512sums="
+01c529e3207738d8771caeb5ed6217e10745c21aa39832fe3185e1c87fdb6aedead97ce38dbb11e02d873654028bd8071c3f345c18452769520723284efe9dc1 Python-3.9.6.tar.xz
+9423cb60d15a6f068838497a1eaea9f5a32d70c07191c313ba821a6919d6e0c436ada4f547cc5f2db5eacc0123429ad54851f57df2554f61fa293743ec14a033 bluez-5.55.tar.xz
+fe123dd871f7a3fa868c499a957b94f1d815a1e1de964aaff1116c579defd4d9d1e9b7eb418cf114b169b97426ed603bf4b1e61b45ec483df06abe988c6a30ee fix-xattrs-glibc.patch
ab8eaa2858d5109049b1f9f553198d40e0ef8d78211ad6455f7b491af525bffb16738fed60fc84e960c4889568d25753b9e4a1494834fea48291b33f07000ec2 musl-find_library.patch
-d489b5d5f374e2b298954a2388771e500c6cf9b274012e06b3e71a34aa85c354369b3fa2a37c3121808075c1f1f340a9fa097996c149399e10b9424170211d90 custom-bluetooth-h-path.patch
+6b04a779f0aaf243d398fe28207a7257d74e6fb0487b05fbb6bf56d4f1b842714f51fcb4953214b25c7552d688e8b98d2ef63ef6c29ebed194b9a80870db2d98 custom-bluetooth-h-path.patch
a84483246e413650a904c34c18f5e4f4168c39067d069f48557c330de6eb3db19fd96a4d453d742db3dcb7c7f962722903f62823c752ff90510c89830435ffc0 arm-alignment.patch
d95e36ef3c315a2ddf689c9319e027cf56e8817b0cae139e3ade4742ab6f9efcb3cc4adca178e9bbc8757bd0e3fb924ac2b37e66e70eaa7288202a25339eed7d mpdecimal-2.5.1.patch
-f0b2da4937cac618c40b9e2b6e332de321cd6d292820f11a74122a6c1440f4dadc73dead6a1cf07ea54af3c4db66e0ba38af83f139f7d5f77d479c179376139d test_nntplib.patch
-62b9b25c40e1fe2bfd068cfa056fb7a0a8d5ef1b00256a216efbaa7c36c2fc2f292e20776ccf7c43affb427232b2e6b9348845076e29f9621e48b06fc13e29e2 ece5dfd403dac211f8d3c72701fe7ba7b7aa5b5f.patch"
+68a3b0bc270e4f7ec8593945c8c891fab988489f4ba9ee78a0e4351df0699db16dfad7d374f13758c80962b0cea048ff577c0462857cd13919d6cefa1f6a382f bpo-43112.patch
+"
diff --git a/main/python3/bpo-43112.patch b/main/python3/bpo-43112.patch
new file mode 100644
index 0000000000..7c2e0c7fde
--- /dev/null
+++ b/main/python3/bpo-43112.patch
@@ -0,0 +1,211 @@
+From 82bf05d215dfcc2ef779395bf79b5fc23d5b9555 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 10 Feb 2021 18:36:04 +0100
+Subject: [PATCH 1/4] bpo-43112: detect musl as a separate SOABI
+
+musl libc and gnu libc are not ABI compatible so we need set different
+SOABI for musl and not simply assume that all linux is linux-gnu.
+
+Replace linux-gnu with the detected os for the build from config.guess
+for linux-musl*.
+---
+ configure.ac | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/configure.ac b/configure.ac
+index 60c5d8e0b5b03..0e6b617080123 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -860,6 +860,11 @@ EOF
+
+ if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
+ PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '`
++ case "$build_os" in
++ linux-musl*)
++ PLATFORM_TRIPLET=`echo "$PLATFORM_TRIPLET" | sed 's/linux-gnu/linux-musl/'`
++ ;;
++ esac
+ AC_MSG_RESULT([$PLATFORM_TRIPLET])
+ else
+ AC_MSG_RESULT([none])
+
+From a2f26c78cfa7e41dea21d7adcf59809b3b933adf Mon Sep 17 00:00:00 2001
+From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com>
+Date: Wed, 10 Feb 2021 17:54:06 +0000
+Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?=
+ =?UTF-8?q?rb=5Fit.?=
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+---
+ Misc/NEWS.d/next/Build/2021-02-10-17-54-04.bpo-43112.H5Lat6.rst | 1 +
+ 1 file changed, 1 insertion(+)
+ create mode 100644 Misc/NEWS.d/next/Build/2021-02-10-17-54-04.bpo-43112.H5Lat6.rst
+
+diff --git a/Misc/NEWS.d/next/Build/2021-02-10-17-54-04.bpo-43112.H5Lat6.rst b/Misc/NEWS.d/next/Build/2021-02-10-17-54-04.bpo-43112.H5Lat6.rst
+new file mode 100644
+index 0000000000000..8da82f85b4908
+--- /dev/null
++++ b/Misc/NEWS.d/next/Build/2021-02-10-17-54-04.bpo-43112.H5Lat6.rst
+@@ -0,0 +1 @@
++Detect musl libc as a separate SOABI.
+\ No newline at end of file
+
+From e45d9f5889a49bb66d67d7a79df364fe9e1accd1 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 10 Feb 2021 20:04:11 +0100
+Subject: [PATCH 3/4] regenerate configure
+
+---
+ configure | 19 ++++++++++++++++++-
+ 1 file changed, 18 insertions(+), 1 deletion(-)
+
+diff --git a/configure b/configure
+index 8e0cc71a50480..4183b10fbb17b 100755
+--- a/configure
++++ b/configure
+@@ -789,6 +789,7 @@ infodir
+ docdir
+ oldincludedir
+ includedir
++runstatedir
+ localstatedir
+ sharedstatedir
+ sysconfdir
+@@ -910,6 +911,7 @@ datadir='${datarootdir}'
+ sysconfdir='${prefix}/etc'
+ sharedstatedir='${prefix}/com'
+ localstatedir='${prefix}/var'
++runstatedir='${localstatedir}/run'
+ includedir='${prefix}/include'
+ oldincludedir='/usr/include'
+ docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+@@ -1162,6 +1164,15 @@ do
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
++ -runstatedir | --runstatedir | --runstatedi | --runstated \
++ | --runstate | --runstat | --runsta | --runst | --runs \
++ | --run | --ru | --r)
++ ac_prev=runstatedir ;;
++ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
++ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
++ | --run=* | --ru=* | --r=*)
++ runstatedir=$ac_optarg ;;
++
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+@@ -1299,7 +1310,7 @@ fi
+ for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
+ datadir sysconfdir sharedstatedir localstatedir includedir \
+ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+- libdir localedir mandir
++ libdir localedir mandir runstatedir
+ do
+ eval ac_val=\$$ac_var
+ # Remove trailing slashes.
+@@ -1452,6 +1463,7 @@ Fine tuning of the installation directories:
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
++ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+@@ -5351,6 +5363,11 @@ EOF
+
+ if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
+ PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '`
++ case "$build_os" in
++ linux-musl*)
++ PLATFORM_TRIPLET=`echo "$PLATFORM_TRIPLET" | sed 's/linux-gnu/linux-musl/'`
++ ;;
++ esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PLATFORM_TRIPLET" >&5
+ $as_echo "$PLATFORM_TRIPLET" >&6; }
+ else
+
+From 85e060266dae2e5e6bbbd7f5fe828f8916651b8b Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Fri, 12 Feb 2021 10:55:48 +0100
+Subject: [PATCH 4/4] Revert the runstate changes in the generated configure
+
+---
+ configure | 14 +-------------
+ 1 file changed, 1 insertion(+), 13 deletions(-)
+
+diff --git a/configure b/configure
+index 4183b10fbb17b..cb1ef8612dcb7 100755
+--- a/configure
++++ b/configure
+@@ -789,7 +789,6 @@ infodir
+ docdir
+ oldincludedir
+ includedir
+-runstatedir
+ localstatedir
+ sharedstatedir
+ sysconfdir
+@@ -911,7 +910,6 @@ datadir='${datarootdir}'
+ sysconfdir='${prefix}/etc'
+ sharedstatedir='${prefix}/com'
+ localstatedir='${prefix}/var'
+-runstatedir='${localstatedir}/run'
+ includedir='${prefix}/include'
+ oldincludedir='/usr/include'
+ docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+@@ -1164,15 +1162,6 @@ do
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+- -runstatedir | --runstatedir | --runstatedi | --runstated \
+- | --runstate | --runstat | --runsta | --runst | --runs \
+- | --run | --ru | --r)
+- ac_prev=runstatedir ;;
+- -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+- | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+- | --run=* | --ru=* | --r=*)
+- runstatedir=$ac_optarg ;;
+-
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+@@ -1310,7 +1299,7 @@ fi
+ for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
+ datadir sysconfdir sharedstatedir localstatedir includedir \
+ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+- libdir localedir mandir runstatedir
++ libdir localedir mandir
+ do
+ eval ac_val=\$$ac_var
+ # Remove trailing slashes.
+@@ -1463,7 +1452,6 @@ Fine tuning of the installation directories:
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+- --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
+index e279957e26..83ce74aa6f 100644
+--- a/Lib/test/test_sysconfig.py
++++ b/Lib/test/test_sysconfig.py
+@@ -387,10 +387,13 @@ def test_triplet_in_ext_suffix(self):
+ if re.match('(i[3-6]86|x86_64)$', machine):
+ if ctypes.sizeof(ctypes.c_char_p()) == 4:
+ self.assertTrue(suffix.endswith('i386-linux-gnu.so') or
+- suffix.endswith('x86_64-linux-gnux32.so'),
++ suffix.endswith('x86_64-linux-gnux32.so') or
++ suffix.endswith('i386-linux-musl.so'),
+ suffix)
+ else: # 8 byte pointer size
+- self.assertTrue(suffix.endswith('x86_64-linux-gnu.so'), suffix)
++ self.assertTrue(suffix.endswith('x86_64-linux-gnu.so') or
++ suffix.endswith('x86_64-linux-musl.so'),
++ suffix)
+
+ @unittest.skipUnless(sys.platform == 'darwin', 'OS X-specific test')
+ def test_osx_ext_suffix(self):
diff --git a/main/python3/custom-bluetooth-h-path.patch b/main/python3/custom-bluetooth-h-path.patch
index 518ab57d4b..85fe92b222 100644
--- a/main/python3/custom-bluetooth-h-path.patch
+++ b/main/python3/custom-bluetooth-h-path.patch
@@ -1,15 +1,15 @@
diff --git a/configure.ac b/configure.ac
-index e57ef7c..f15a4ea 100644
+index c968d14..5b2793e 100644
--- a/configure.ac
+++ b/configure.ac
-@@ -2145,16 +2145,27 @@ sys/kern_control.h sys/loadavg.h sys/lock.h sys/mkdev.h sys/modem.h \
+@@ -2205,16 +2205,27 @@ sys/kern_control.h sys/loadavg.h sys/lock.h sys/mkdev.h sys/modem.h \
sys/param.h sys/random.h sys/select.h sys/sendfile.h sys/socket.h sys/statvfs.h \
sys/stat.h sys/syscall.h sys/sys_domain.h sys/termio.h sys/time.h \
sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \
-libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
+libutil.h sys/resource.h netpacket/packet.h sysexits.h \
linux/tipc.h linux/random.h spawn.h util.h alloca.h endian.h \
- sys/endian.h sys/sysmacros.h linux/memfd.h sys/memfd.h sys/mman.h)
+ sys/endian.h sys/sysmacros.h linux/memfd.h linux/wait.h sys/memfd.h sys/mman.h)
AC_HEADER_DIRENT
AC_HEADER_MAJOR
@@ -33,20 +33,25 @@ index e57ef7c..f15a4ea 100644
CFLAGS=$SAVE_CFLAGS
diff --git a/setup.py b/setup.py
-index 20d7f35..5d8ab7e 100644
+index bd5f736..9381135 100644
--- a/setup.py
+++ b/setup.py
-@@ -1041,15 +1041,18 @@ class PyBuildExt(build_ext):
+@@ -1127,6 +1127,7 @@ class PyBuildExt(build_ext):
libraries=libs))
def detect_socket(self):
+ bluetooth_includes = [@bluetoothdir@]
# socket(2)
if not VXWORKS:
- self.add(Extension('_socket', ['socketmodule.c'],
-- depends=['socketmodule.h']))
-+ depends=['socketmodule.h'],
-+ include_dirs=bluetooth_includes))
+ kwargs = {'depends': ['socketmodule.h']}
+@@ -1134,12 +1135,15 @@ class PyBuildExt(build_ext):
+ # Issue #35569: Expose RFC 3542 socket options.
+ kwargs['extra_compile_args'] = ['-D__APPLE_USE_RFC_3542']
+
+- self.add(Extension('_socket', ['socketmodule.c'], **kwargs))
++ self.add(Extension('_socket', ['socketmodule.c'],
++ include_dirs=bluetooth_includes,
++ **kwargs))
elif self.compiler.find_library_file(self.lib_dirs, 'net'):
libs = ['net']
self.add(Extension('_socket', ['socketmodule.c'],
@@ -57,7 +62,7 @@ index 20d7f35..5d8ab7e 100644
def detect_dbm_gdbm(self):
# Modules that provide persistent dictionary-like semantics. You will
-@@ -2203,6 +2206,7 @@ class PyBuildExt(build_ext):
+@@ -2322,6 +2326,7 @@ class PyBuildExt(build_ext):
return [v.strip() for v in value.split(sep) if v.strip()]
openssl_includes = split_var('OPENSSL_INCLUDES', '-I')
diff --git a/main/python3/ece5dfd403dac211f8d3c72701fe7ba7b7aa5b5f.patch b/main/python3/ece5dfd403dac211f8d3c72701fe7ba7b7aa5b5f.patch
deleted file mode 100644
index 9f32054f38..0000000000
--- a/main/python3/ece5dfd403dac211f8d3c72701fe7ba7b7aa5b5f.patch
+++ /dev/null
@@ -1,186 +0,0 @@
-From ece5dfd403dac211f8d3c72701fe7ba7b7aa5b5f Mon Sep 17 00:00:00 2001
-From: "Miss Islington (bot)"
- <31488909+miss-islington@users.noreply.github.com>
-Date: Mon, 18 Jan 2021 13:28:52 -0800
-Subject: [PATCH] closes bpo-42938: Replace snprintf with Python unicode
- formatting in ctypes param reprs. (GH-24248)
-
-(cherry picked from commit 916610ef90a0d0761f08747f7b0905541f0977c7)
-
-Co-authored-by: Benjamin Peterson <benjamin@python.org>
-
-Co-authored-by: Benjamin Peterson <benjamin@python.org>
----
- Lib/ctypes/test/test_parameters.py | 43 ++++++++++++++++
- .../2021-01-18-09-27-31.bpo-42938.4Zn4Mp.rst | 2 +
- Modules/_ctypes/callproc.c | 51 +++++++------------
- 3 files changed, 64 insertions(+), 32 deletions(-)
- create mode 100644 Misc/NEWS.d/next/Security/2021-01-18-09-27-31.bpo-42938.4Zn4Mp.rst
-
-diff --git a/Lib/ctypes/test/test_parameters.py b/Lib/ctypes/test/test_parameters.py
-index e4c25fd880cef..531894fdec838 100644
---- a/Lib/ctypes/test/test_parameters.py
-+++ b/Lib/ctypes/test/test_parameters.py
-@@ -201,6 +201,49 @@ def __dict__(self):
- with self.assertRaises(ZeroDivisionError):
- WorseStruct().__setstate__({}, b'foo')
-
-+ def test_parameter_repr(self):
-+ from ctypes import (
-+ c_bool,
-+ c_char,
-+ c_wchar,
-+ c_byte,
-+ c_ubyte,
-+ c_short,
-+ c_ushort,
-+ c_int,
-+ c_uint,
-+ c_long,
-+ c_ulong,
-+ c_longlong,
-+ c_ulonglong,
-+ c_float,
-+ c_double,
-+ c_longdouble,
-+ c_char_p,
-+ c_wchar_p,
-+ c_void_p,
-+ )
-+ self.assertRegex(repr(c_bool.from_param(True)), r"^<cparam '\?' at 0x[A-Fa-f0-9]+>$")
-+ self.assertEqual(repr(c_char.from_param(97)), "<cparam 'c' ('a')>")
-+ self.assertRegex(repr(c_wchar.from_param('a')), r"^<cparam 'u' at 0x[A-Fa-f0-9]+>$")
-+ self.assertEqual(repr(c_byte.from_param(98)), "<cparam 'b' (98)>")
-+ self.assertEqual(repr(c_ubyte.from_param(98)), "<cparam 'B' (98)>")
-+ self.assertEqual(repr(c_short.from_param(511)), "<cparam 'h' (511)>")
-+ self.assertEqual(repr(c_ushort.from_param(511)), "<cparam 'H' (511)>")
-+ self.assertRegex(repr(c_int.from_param(20000)), r"^<cparam '[li]' \(20000\)>$")
-+ self.assertRegex(repr(c_uint.from_param(20000)), r"^<cparam '[LI]' \(20000\)>$")
-+ self.assertRegex(repr(c_long.from_param(20000)), r"^<cparam '[li]' \(20000\)>$")
-+ self.assertRegex(repr(c_ulong.from_param(20000)), r"^<cparam '[LI]' \(20000\)>$")
-+ self.assertRegex(repr(c_longlong.from_param(20000)), r"^<cparam '[liq]' \(20000\)>$")
-+ self.assertRegex(repr(c_ulonglong.from_param(20000)), r"^<cparam '[LIQ]' \(20000\)>$")
-+ self.assertEqual(repr(c_float.from_param(1.5)), "<cparam 'f' (1.5)>")
-+ self.assertEqual(repr(c_double.from_param(1.5)), "<cparam 'd' (1.5)>")
-+ self.assertEqual(repr(c_double.from_param(1e300)), "<cparam 'd' (1e+300)>")
-+ self.assertRegex(repr(c_longdouble.from_param(1.5)), r"^<cparam ('d' \(1.5\)|'g' at 0x[A-Fa-f0-9]+)>$")
-+ self.assertRegex(repr(c_char_p.from_param(b'hihi')), "^<cparam 'z' \(0x[A-Fa-f0-9]+\)>$")
-+ self.assertRegex(repr(c_wchar_p.from_param('hihi')), "^<cparam 'Z' \(0x[A-Fa-f0-9]+\)>$")
-+ self.assertRegex(repr(c_void_p.from_param(0x12)), r"^<cparam 'P' \(0x0*12\)>$")
-+
- ################################################################
-
- if __name__ == '__main__':
-diff --git a/Misc/NEWS.d/next/Security/2021-01-18-09-27-31.bpo-42938.4Zn4Mp.rst b/Misc/NEWS.d/next/Security/2021-01-18-09-27-31.bpo-42938.4Zn4Mp.rst
-new file mode 100644
-index 0000000000000..7df65a156feab
---- /dev/null
-+++ b/Misc/NEWS.d/next/Security/2021-01-18-09-27-31.bpo-42938.4Zn4Mp.rst
-@@ -0,0 +1,2 @@
-+Avoid static buffers when computing the repr of :class:`ctypes.c_double` and
-+:class:`ctypes.c_longdouble` values.
-diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
-index a9b8675cd951b..de75918d49f37 100644
---- a/Modules/_ctypes/callproc.c
-+++ b/Modules/_ctypes/callproc.c
-@@ -484,58 +484,47 @@ is_literal_char(unsigned char c)
- static PyObject *
- PyCArg_repr(PyCArgObject *self)
- {
-- char buffer[256];
- switch(self->tag) {
- case 'b':
- case 'B':
-- sprintf(buffer, "<cparam '%c' (%d)>",
-+ return PyUnicode_FromFormat("<cparam '%c' (%d)>",
- self->tag, self->value.b);
-- break;
- case 'h':
- case 'H':
-- sprintf(buffer, "<cparam '%c' (%d)>",
-+ return PyUnicode_FromFormat("<cparam '%c' (%d)>",
- self->tag, self->value.h);
-- break;
- case 'i':
- case 'I':
-- sprintf(buffer, "<cparam '%c' (%d)>",
-+ return PyUnicode_FromFormat("<cparam '%c' (%d)>",
- self->tag, self->value.i);
-- break;
- case 'l':
- case 'L':
-- sprintf(buffer, "<cparam '%c' (%ld)>",
-+ return PyUnicode_FromFormat("<cparam '%c' (%ld)>",
- self->tag, self->value.l);
-- break;
-
- case 'q':
- case 'Q':
-- sprintf(buffer,
--#ifdef MS_WIN32
-- "<cparam '%c' (%I64d)>",
--#else
-- "<cparam '%c' (%lld)>",
--#endif
-+ return PyUnicode_FromFormat("<cparam '%c' (%lld)>",
- self->tag, self->value.q);
-- break;
- case 'd':
-- sprintf(buffer, "<cparam '%c' (%f)>",
-- self->tag, self->value.d);
-- break;
-- case 'f':
-- sprintf(buffer, "<cparam '%c' (%f)>",
-- self->tag, self->value.f);
-- break;
--
-+ case 'f': {
-+ PyObject *f = PyFloat_FromDouble((self->tag == 'f') ? self->value.f : self->value.d);
-+ if (f == NULL) {
-+ return NULL;
-+ }
-+ PyObject *result = PyUnicode_FromFormat("<cparam '%c' (%R)>", self->tag, f);
-+ Py_DECREF(f);
-+ return result;
-+ }
- case 'c':
- if (is_literal_char((unsigned char)self->value.c)) {
-- sprintf(buffer, "<cparam '%c' ('%c')>",
-+ return PyUnicode_FromFormat("<cparam '%c' ('%c')>",
- self->tag, self->value.c);
- }
- else {
-- sprintf(buffer, "<cparam '%c' ('\\x%02x')>",
-+ return PyUnicode_FromFormat("<cparam '%c' ('\\x%02x')>",
- self->tag, (unsigned char)self->value.c);
- }
-- break;
-
- /* Hm, are these 'z' and 'Z' codes useful at all?
- Shouldn't they be replaced by the functionality of c_string
-@@ -544,22 +533,20 @@ PyCArg_repr(PyCArgObject *self)
- case 'z':
- case 'Z':
- case 'P':
-- sprintf(buffer, "<cparam '%c' (%p)>",
-+ return PyUnicode_FromFormat("<cparam '%c' (%p)>",
- self->tag, self->value.p);
- break;
-
- default:
- if (is_literal_char((unsigned char)self->tag)) {
-- sprintf(buffer, "<cparam '%c' at %p>",
-+ return PyUnicode_FromFormat("<cparam '%c' at %p>",
- (unsigned char)self->tag, (void *)self);
- }
- else {
-- sprintf(buffer, "<cparam 0x%02x at %p>",
-+ return PyUnicode_FromFormat("<cparam 0x%02x at %p>",
- (unsigned char)self->tag, (void *)self);
- }
-- break;
- }
-- return PyUnicode_FromString(buffer);
- }
-
- static PyMemberDef PyCArgType_members[] = {
diff --git a/main/python3/fix-xattrs-glibc.patch b/main/python3/fix-xattrs-glibc.patch
index 57a8fb73ab..871236f66b 100644
--- a/main/python3/fix-xattrs-glibc.patch
+++ b/main/python3/fix-xattrs-glibc.patch
@@ -1,15 +1,15 @@
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
-index 8f8ba25..72b92da 100644
+index 12f72f5..d54d085 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
-@@ -103,8 +103,9 @@ corresponding Unix manual entries for more information on calls.");
- #undef HAVE_SCHED_SETAFFINITY
+@@ -234,8 +234,9 @@ corresponding Unix manual entries for more information on calls.");
+ # undef HAVE_SCHED_SETAFFINITY
#endif
-#if defined(HAVE_SYS_XATTR_H) && defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__)
+#if defined(HAVE_SYS_XATTR_H) && defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__)
- #define USE_XATTRS
-+#include <linux/limits.h>
+ # define USE_XATTRS
++# include <linux/limits.h>
#endif
#ifdef USE_XATTRS
diff --git a/main/python3/test_nntplib.patch b/main/python3/test_nntplib.patch
deleted file mode 100644
index d1d94031fd..0000000000
--- a/main/python3/test_nntplib.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-diff --git a/Lib/test/test_nntplib.py b/Lib/test/test_nntplib.py
-index fbd7db03defb1..89a2004dfb139 100644
---- a/Lib/test/test_nntplib.py
-+++ b/Lib/test/test_nntplib.py
-@@ -82,7 +82,7 @@ def _check_desc(desc):
- desc = self.server.description(self.GROUP_NAME)
- _check_desc(desc)
- # Another sanity check
-- self.assertIn("Python", desc)
-+ self.assertIn(self.DESC, desc)
- # With a pattern
- desc = self.server.description(self.GROUP_PAT)
- _check_desc(desc)
-@@ -299,6 +299,7 @@ class NetworkedNNTPTests(NetworkedNNTPTestsMixin, unittest.TestCase):
- NNTP_HOST = 'news.trigofacile.com'
- GROUP_NAME = 'fr.comp.lang.python'
- GROUP_PAT = 'fr.comp.lang.*'
-+ DESC = 'Python'
-
- NNTP_CLASS = NNTP
-
-@@ -332,8 +333,11 @@ class NetworkedNNTP_SSLTests(NetworkedNNTPTests):
- # 400 connections per day are accepted from each IP address."
-
- NNTP_HOST = 'nntp.aioe.org'
-- GROUP_NAME = 'comp.lang.python'
-- GROUP_PAT = 'comp.lang.*'
-+ # bpo-42794: aioe.test is one of the official groups on this server
-+ # used for testing: https://news.aioe.org/manual/aioe-hierarchy/
-+ GROUP_NAME = 'aioe.test'
-+ GROUP_PAT = 'aioe.*'
-+ DESC = 'test'
-
- NNTP_CLASS = getattr(nntplib, 'NNTP_SSL', None)