[rtems-source-builder commit] source-builder: Handle utf8 in path

Joel Sherrill joel at rtems.org
Mon May 16 22:30:27 UTC 2022


Module:    rtems-source-builder
Branch:    master
Commit:    620b62436ad28e72c935032157f23df6d9723c69
Changeset: http://git.rtems.org/rtems-source-builder/commit/?id=620b62436ad28e72c935032157f23df6d9723c69

Author:    Kinsey Moore <kinsey.moore at oarcorp.com>
Date:      Wed May 11 16:22:57 2022 -0500

source-builder: Handle utf8 in path

It's possible for an environment to have unicode characters in its
paths. This was recently exposed by the latest newlib update and RSB
fails under Python 2.7 in this situation. This resolves the issue by
ensuring that the paths are encoded and decoded as necessary.

Related issue that caused the change in newlib:
https://github.com/golang/go/issues/27836

---

 source-builder/sb/path.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/source-builder/sb/path.py b/source-builder/sb/path.py
index b27cf14..d36e12a 100644
--- a/source-builder/sb/path.py
+++ b/source-builder/sb/path.py
@@ -58,7 +58,7 @@ def host(path):
 
 def shell(path):
     if isinstance(path, bytes):
-        path = path.decode('ascii')
+        path = path.decode('utf8')
     if path is not None:
         if windows or windows_posix:
             path = path.encode('ascii', 'ignore').decode('ascii')
@@ -189,11 +189,11 @@ def removeall(path):
     # get to the max path length on Windows.
     #
     def _isdir(path):
-        hpath = host(path)
+        hpath = host(path).encode('utf8')
         return os.path.isdir(hpath) and not os.path.islink(hpath)
 
     def _remove_node(path):
-        hpath = host(path)
+        hpath = host(path).encode('utf8')
         if not os.path.islink(hpath) and not os.access(hpath, os.W_OK):
             os.chmod(hpath, stat.S_IWUSR)
         if _isdir(path):
@@ -216,7 +216,7 @@ def removeall(path):
             _remove_node(dir)
 
     path = shell(path)
-    hpath = host(path)
+    hpath = host(path).encode('utf8')
 
     if os.path.exists(hpath):
         _remove(path)
@@ -317,11 +317,11 @@ def get_size(path, depth = -1):
     # get to the max path length on Windows.
     #
     def _isdir(path):
-        hpath = host(path)
+        hpath = host(path).encode('utf8')
         return os.path.isdir(hpath) and not os.path.islink(hpath)
 
     def _node_size(path):
-        hpath = host(path)
+        hpath = host(path).encode('utf8')
         size = 0
         if not os.path.islink(hpath):
             size = os.path.getsize(hpath)
@@ -345,7 +345,7 @@ def get_size(path, depth = -1):
         return size
 
     path = shell(path)
-    hpath = host(path)
+    hpath = host(path).encode('utf8')
     size = 0
 
     if os.path.exists(hpath):



More information about the vc mailing list