diff cutils/util/walk.py @ 368:7761a15b9736

treesum: Escape `\' using `\\' instead of `\x5c'. Wished by sbro. BUGS: Escaping should be controllable by a commandline option.
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 10 Apr 2025 11:58:36 +0200
parents b256ae4f4bc8
children 04d7945ff4ae
line wrap: on
line diff
--- a/cutils/util/walk.py	Thu Apr 10 01:54:09 2025 +0200
+++ b/cutils/util/walk.py	Thu Apr 10 11:58:36 2025 +0200
@@ -220,12 +220,12 @@
         #     with it
         #
         if isinstance(what, bytes):
-            s = (what.replace(b'\\', b"\\x5c")
+            s = (what.replace(b'\\', b"\\\\")
                  .replace(b'\n', b"\\x0a")
                  .replace(b'\r', b"\\x0d")
                  .replace(b'\t', b"\\x09"))
         else:
-            s = (what.replace(u'\\', u"\\x5c")
+            s = (what.replace(u'\\', u"\\\\")
                  .replace(u'\n', u"\\x0a")
                  .replace(u'\r', u"\\x0d")
                  .replace(u'\t', u"\\x09"))
@@ -329,12 +329,12 @@
         #     with it
         #
         if isinstance(what, bytes):
-            s = (what.replace(b'\\', b"\\x5c")
+            s = (what.replace(b'\\', b"\\\\")
                  .replace(b'\n', b"\\x0a")
                  .replace(b'\r', b"\\x0d")
                  .replace(b'\t', b"\\x09"))
         else:
-            s = (what.replace(u'\\', u"\\x5c")
+            s = (what.replace(u'\\', u"\\\\")
                  .replace(u'\n', u"\\x0a")
                  .replace(u'\r', u"\\x0d")
                  .replace(u'\t', u"\\x09"))