unvendorable surrogateescape (#887);

stolen/surrogateescape.py can be deleted;
this file is only necessary for python2 compatibility
This commit is contained in:
ed 2025-10-04 22:10:34 +00:00
parent 39bd4e5b58
commit aace711eb9
2 changed files with 22 additions and 3 deletions

View file

@ -55,7 +55,6 @@ from .__init__ import (
unicode, unicode,
) )
from .__version__ import S_BUILD_DT, S_VERSION from .__version__ import S_BUILD_DT, S_VERSION
from .stolen import surrogateescape
try: try:
from datetime import datetime, timezone from datetime import datetime, timezone
@ -81,6 +80,9 @@ except:
if PY2: if PY2:
range = xrange # type: ignore range = xrange # type: ignore
from .stolen import surrogateescape
surrogateescape.register_surrogateescape()
if sys.version_info >= (3, 7) or ( if sys.version_info >= (3, 7) or (
@ -293,7 +295,6 @@ RE_MEMAVAIL = re.compile("^MemAvailable:.* kB")
BOS_SEP = ("%s" % (os.sep,)).encode("ascii") BOS_SEP = ("%s" % (os.sep,)).encode("ascii")
surrogateescape.register_surrogateescape()
if WINDOWS and PY2: if WINDOWS and PY2:
FS_ENCODING = "utf-8" FS_ENCODING = "utf-8"
else: else:

View file

@ -1,6 +1,19 @@
#!/bin/ash #!/bin/ash
set -ex 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 # use zlib-ng if available
f=/z/base/zlib_ng-0.5.1-cp312-cp312-linux_$(cat /etc/apk/arch).whl f=/z/base/zlib_ng-0.5.1-cp312-cp312-linux_$(cat /etc/apk/arch).whl
[ "$1" != min ] && [ -e $f ] && { [ "$1" != min ] && [ -e $f ] && {
@ -38,8 +51,13 @@ rm -rf \
/tmp/pe-* /z/copyparty-sfx.py \ /tmp/pe-* /z/copyparty-sfx.py \
ensurepip pydoc_data turtle.py turtledemo lib2to3 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 # 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 # drop bytecode
find / -xdev -name __pycache__ -print0 | xargs -0 rm -rf find / -xdev -name __pycache__ -print0 | xargs -0 rm -rf