Use chr instead of unichr
[mudpy.git] / lib / mudpy / misc.py
index 8f6630f..2fe8e6f 100644 (file)
@@ -808,7 +808,7 @@ class User:
                     "\r\n\r\n"
                 ):
                     output = "$(eol)" + output
-            output += eol + unichr(27) + "[0m"
+            output += eol + chr(27) + "[0m"
 
             # tack on a prompt if active
             if self.state == "active":
@@ -1354,15 +1354,15 @@ def replace_macros(user, text, is_input=False):
     # a dict of replacement macros
     macros = {
         "eol": "\r\n",
-        "bld": unichr(27) + "[1m",
-        "nrm": unichr(27) + "[0m",
-        "blk": unichr(27) + "[30m",
-        "blu": unichr(27) + "[34m",
-        "cyn": unichr(27) + "[36m",
-        "grn": unichr(27) + "[32m",
-        "mgt": unichr(27) + "[35m",
-        "red": unichr(27) + "[31m",
-        "yel": unichr(27) + "[33m",
+        "bld": chr(27) + "[1m",
+        "nrm": chr(27) + "[0m",
+        "blk": chr(27) + "[30m",
+        "blu": chr(27) + "[34m",
+        "cyn": chr(27) + "[36m",
+        "grn": chr(27) + "[32m",
+        "mgt": chr(27) + "[35m",
+        "red": chr(27) + "[31m",
+        "yel": chr(27) + "[33m",
     }
 
     # add dynamic macros where possible
@@ -2442,9 +2442,8 @@ def daemonize(universe):
     if universe.contents["internal:process"].getboolean("daemon"):
 
         # if possible, we want to rename the process to the same as the script
-        # (these will need to be byte type during 2to3 migration)
-        new_argv = "\0".join(sys.argv) + "\0"
-        new_short_argv0 = os.path.basename(sys.argv[0]) + "\0"
+        new_argv = b"\x00".join(x.encode("utf-8") for x in sys.argv) + b"\x00"
+        short_argv0 = os.path.basename(sys.argv[0]).encode("utf-8") + b"\x00"
 
         # attempt the linux way first
         try:
@@ -2463,7 +2462,7 @@ def daemonize(universe):
             ctypes.memmove(argc.contents, new_argv, len(new_argv))
             ctypes.CDLL(ctypes.util.find_library("c")).prctl(
                 15,
-                new_short_argv0,
+                short_argv0,
                 0,
                 0,
                 0