commit 0d0feb55b702f496eed70e3dd43027c2d7079f77
parent 6d990a29b8697dea8aab41a47035f1bcb0fbda59
Author: Sandor Molnar <smolnar@mozilla.com>
Date: Mon, 8 Dec 2025 18:04:21 +0200
Revert "Bug 2002887 - Special manifestparser.util.normsep based on os property r=jcristau" for causing lint failures
This reverts commit c7f06c1d73d244215e40c80969c4f0c7af9acd11.
Diffstat:
1 file changed, 17 insertions(+), 46 deletions(-)
diff --git a/testing/mozbase/manifestparser/manifestparser/util.py b/testing/mozbase/manifestparser/manifestparser/util.py
@@ -5,54 +5,25 @@
import ast
import os
-# The normsep function is used everywhere, it's important enough in terms of
-# optimization to justify the slight duplication that can be found below.
-#
-# TODO: Have a dedicated function for bytes and one for unicode.
-if os.altsep and os.altsep != "/":
- altsep_b = os.altsep.encode("ascii")
-if os.sep != "/":
- sep_b = os.sep.encode("ascii")
-if os.sep != "/":
- if os.altsep and os.altsep != "/":
-
- def normsep(path):
- """
- Normalize path separators, by using forward slashes instead of whatever
- :py:const:`os.sep` is.
- """
- # Python 2 is happy to do things like byte_string.replace(u'foo',
- # u'bar'), but not Python 3.
- if isinstance(path, bytes):
- path = path.replace(sep_b, b"/")
- return path.replace(altsep_b, b"/")
- else:
- path = path.replace(os.sep, "/")
- return path.replace(os.altsep, "/")
-
- else:
-
- def normsep(path):
- if isinstance(path, bytes):
- return path.replace(sep_b, b"/")
- else:
- return path.replace(os.sep, "/")
-
-else:
+def normsep(path):
+ """
+ Normalize path separators, by using forward slashes instead of whatever
+ :py:const:`os.sep` is.
+ """
+ if os.sep != "/":
+ # Python 2 is happy to do things like byte_string.replace(u'foo',
+ # u'bar'), but not Python 3.
+ if isinstance(path, bytes):
+ path = path.replace(os.sep.encode("ascii"), b"/")
+ else:
+ path = path.replace(os.sep, "/")
if os.altsep and os.altsep != "/":
-
- def normsep(path):
- if isinstance(path, bytes):
- return path.replace(altsep_b, b"/")
- else:
- return path.replace(os.altsep, "/")
- return path
-
- else:
-
- def normsep(path):
- return path
+ if isinstance(path, bytes):
+ path = path.replace(os.altsep.encode("ascii"), b"/")
+ else:
+ path = path.replace(os.altsep, "/")
+ return path
def evaluate_list_from_string(list_string):