From aace711eb9494b31afe0b5f1bd79731b54d12d9c Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 4 Oct 2025 22:10:34 +0000 Subject: [PATCH] unvendorable surrogateescape (#887); stolen/surrogateescape.py can be deleted; this file is only necessary for python2 compatibility --- copyparty/util.py | 5 +++-- scripts/docker/innvikler.sh | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/copyparty/util.py b/copyparty/util.py index e10ca14d..f75c7b34 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -55,7 +55,6 @@ from .__init__ import ( unicode, ) from .__version__ import S_BUILD_DT, S_VERSION -from .stolen import surrogateescape try: from datetime import datetime, timezone @@ -81,6 +80,9 @@ except: if PY2: range = xrange # type: ignore + from .stolen import surrogateescape + + surrogateescape.register_surrogateescape() if sys.version_info >= (3, 7) or ( @@ -293,7 +295,6 @@ RE_MEMAVAIL = re.compile("^MemAvailable:.* kB") BOS_SEP = ("%s" % (os.sep,)).encode("ascii") -surrogateescape.register_surrogateescape() if WINDOWS and PY2: FS_ENCODING = "utf-8" else: diff --git a/scripts/docker/innvikler.sh b/scripts/docker/innvikler.sh index c027dcca..e79ffde1 100644 --- a/scripts/docker/innvikler.sh +++ b/scripts/docker/innvikler.sh @@ -1,6 +1,19 @@ #!/bin/ash set -ex +tmv() { + touch -r "$1" t + mv t "$1" +} +iawk() { + awk "$1" <"$2" >t + tmv "$2" +} +ised() { + sed -r "$1" <"$2" >t + tmv "$2" +} + # use zlib-ng if available f=/z/base/zlib_ng-0.5.1-cp312-cp312-linux_$(cat /etc/apk/arch).whl [ "$1" != min ] && [ -e $f ] && { @@ -38,8 +51,13 @@ rm -rf \ /tmp/pe-* /z/copyparty-sfx.py \ ensurepip pydoc_data turtle.py turtledemo lib2to3 +cd /usr/lib/python3.*/site-packages/copyparty/ +rm stolen/surrogateescape.py +iawk '/^[^ ]/{s=0}/^if not VENDORED:/{s=1}!s' qrkode.py +iawk '/^[^ ]/{s=0}/^ DNS_VND = False/{s=1;print" raise"}!s' mdns.py + # speedhack -sed -ri 's/os.environ.get\("PRTY_NO_IMPRESO"\)/"1"/' /usr/lib/python3.*/site-packages/copyparty/util.py +ised 's/os.environ.get\("PRTY_NO_IMPRESO"\)/"1"/' util.py # drop bytecode find / -xdev -name __pycache__ -print0 | xargs -0 rm -rf