diff --git a/bin/up2k.py b/bin/up2k.py index ac077b2b..0318a228 100755 --- a/bin/up2k.py +++ b/bin/up2k.py @@ -48,7 +48,7 @@ except ImportError: # from copyparty/__init__.py -PY2 = sys.version_info[0] == 2 +PY2 = sys.version_info < (3,) if PY2: from Queue import Queue from urllib import unquote diff --git a/copyparty/__init__.py b/copyparty/__init__.py index cf7e50f0..8b78a3d2 100644 --- a/copyparty/__init__.py +++ b/copyparty/__init__.py @@ -11,7 +11,7 @@ try: except: TYPE_CHECKING = False -PY2 = sys.version_info[0] == 2 +PY2 = sys.version_info < (3,) if PY2: sys.dont_write_bytecode = True unicode = unicode # noqa: F821 # pylint: disable=undefined-variable,self-assigning-variable diff --git a/copyparty/stolen/surrogateescape.py b/copyparty/stolen/surrogateescape.py index b1ff8886..c11b455f 100644 --- a/copyparty/stolen/surrogateescape.py +++ b/copyparty/stolen/surrogateescape.py @@ -16,7 +16,7 @@ import codecs import platform import sys -PY3 = sys.version_info[0] > 2 +PY3 = sys.version_info > (3,) WINDOWS = platform.system() == "Windows" FS_ERRORS = "surrogateescape" @@ -26,20 +26,6 @@ except: pass -def u(text: Any) -> str: - if PY3: - return text - else: - return text.decode("unicode_escape") - - -def b(data: Any) -> bytes: - if PY3: - return data.encode("latin1") - else: - return data - - if PY3: _unichr = chr bytes_chr = lambda code: bytes((code,)) @@ -171,9 +157,6 @@ def decodefilename(fn: bytes) -> str: FS_ENCODING = sys.getfilesystemencoding() -# FS_ENCODING = "ascii"; fn = b("[abc\xff]"); encoded = u("[abc\udcff]") -# FS_ENCODING = 'cp932'; fn = b('[abc\x81\x00]'); encoded = u('[abc\udc81\x00]') -# FS_ENCODING = 'UTF-8'; fn = b('[abc\xff]'); encoded = u('[abc\udcff]') if WINDOWS and not PY3: diff --git a/copyparty/svchub.py b/copyparty/svchub.py index b3cec559..ecaf7975 100644 --- a/copyparty/svchub.py +++ b/copyparty/svchub.py @@ -480,17 +480,10 @@ class SvcHub(object): print(*a, **ka) def check_mp_support(self) -> str: - vmin = sys.version_info[1] - if WINDOWS: - msg = "need python 3.3 or newer for multiprocessing;" - if PY2 or vmin < 3: - return msg - elif MACOS: + if MACOS: return "multiprocessing is wonky on mac osx;" - else: - msg = "need python 3.3+ for multiprocessing;" - if PY2 or vmin < 3: - return msg + elif sys.version_info < (3, 3): + return "need python 3.3 or newer for multiprocessing;" try: x: mp.Queue[tuple[str, str]] = mp.Queue(1) diff --git a/copyparty/util.py b/copyparty/util.py index 70ea9f8b..d343974a 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -120,7 +120,7 @@ else: FS_ENCODING = sys.getfilesystemencoding() -SYMTIME = sys.version_info >= (3, 6) and os.utime in os.supports_follow_symlinks +SYMTIME = sys.version_info > (3, 6) and os.utime in os.supports_follow_symlinks HTTP_TS_FMT = "%a, %d %b %Y %H:%M:%S GMT" diff --git a/scripts/sfx.py b/scripts/sfx.py index 842a69f3..52ef23dd 100644 --- a/scripts/sfx.py +++ b/scripts/sfx.py @@ -27,7 +27,7 @@ SIZE = None CKSUM = None STAMP = None -PY2 = sys.version_info[0] == 2 +PY2 = sys.version_info < (3,) WINDOWS = sys.platform in ["win32", "msys"] sys.dont_write_bytecode = True me = os.path.abspath(os.path.realpath(__file__))