diff --git a/python/mozbuild/mozpack/path.py b/python/mozbuild/mozpack/path.py index 063d7acb86c7..453bd5353b1c 100644 --- a/python/mozbuild/mozpack/path.py +++ b/python/mozbuild/mozpack/path.py @@ -23,9 +23,17 @@ def normsep(path): :py:const:`os.sep` is. ''' if os.sep != '/': - path = path.replace(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 != '/': - path = path.replace(os.altsep, '/') + if isinstance(path, bytes): + path = path.replace(os.altsep.encode('ascii'), b'/') + else: + path = path.replace(os.altsep, '/') return path