From 49f6e2747bfccaa9612e93c733cb5b0955197601 Mon Sep 17 00:00:00 2001 From: mimihailescu Date: Sun, 14 Jul 2024 10:43:08 +0200 Subject: [PATCH 1/2] added decode bytes to utf-8 --- Lib/shlex.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/shlex.py b/Lib/shlex.py index f4821616b62a0f..5026cdf0195f31 100644 --- a/Lib/shlex.py +++ b/Lib/shlex.py @@ -324,6 +324,10 @@ def quote(s): """Return a shell-escaped version of the string *s*.""" if not s: return "''" + + if isinstance(s, bytes): + s = s.decode('utf-8') + if _find_unsafe(s) is None: return s From d6c1ab5ffe42c21048ea707a8c22a3d3c18ef347 Mon Sep 17 00:00:00 2001 From: mimihailescu Date: Sun, 14 Jul 2024 10:56:15 +0200 Subject: [PATCH 2/2] corrected trailing whitespace --- Lib/shlex.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/shlex.py b/Lib/shlex.py index 5026cdf0195f31..80634088765a1d 100644 --- a/Lib/shlex.py +++ b/Lib/shlex.py @@ -324,10 +324,10 @@ def quote(s): """Return a shell-escaped version of the string *s*.""" if not s: return "''" - + if isinstance(s, bytes): s = s.decode('utf-8') - + if _find_unsafe(s) is None: return s