From 0c1524e5404c49c06565b5e08c9fdf7bce61c165 Mon Sep 17 00:00:00 2001 From: scivision Date: Thu, 14 Sep 2023 08:43:56 -0400 Subject: [PATCH] os.path: refactor: use sep instead of literal / Signed-off-by: Michael Hirsch --- python-stdlib/os-path/os/path.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/python-stdlib/os-path/os/path.py b/python-stdlib/os-path/os/path.py index 7b4f937e5..8d484437a 100644 --- a/python-stdlib/os-path/os/path.py +++ b/python-stdlib/os-path/os/path.py @@ -13,28 +13,28 @@ def normpath(s): def abspath(s): - if s[0] != "/": - return os.getcwd() + "/" + s + if s[0] != sep: + return os.getcwd() + sep + s return s def join(*args): # TODO: this is non-compliant if type(args[0]) is bytes: - return b"/".join(args) + return bytes(sep).join(args) else: - return "/".join(args) + return sep.join(args) def split(path): if path == "": return ("", "") - r = path.rsplit("/", 1) + r = path.rsplit(sep, 1) if len(r) == 1: return ("", path) head = r[0] # .rstrip("/") if not head: - head = "/" + head = sep return (head, r[1]) @@ -67,7 +67,7 @@ def isdir(path): def expanduser(s): - if s == "~" or s.startswith("~/"): + if s == "~" or s.startswith("~" + sep): h = os.getenv("HOME") return h + s[1:] if s[0] == "~":