Fix the testsuite for Python no longer supporting 'rU' in open()
authorAdrian Bunk <bunk@debian.org>
Sat, 19 Nov 2022 10:33:48 +0000 (10:33 +0000)
committerAdrian Bunk <bunk@debian.org>
Sat, 19 Nov 2022 10:33:48 +0000 (10:33 +0000)
Gbp-Pq: Name testsuite-python-open-rU.patch

app/clingo/tests/run.py

index 687089d65426a3c9bece30ad1f0f4174c7d192f6..757a0e73e94e8793e9235df8a95a2f1af2b49f81 100755 (executable)
@@ -115,7 +115,7 @@ if parse_ret.action == "normalize":
     args = [clingo, "0", parse_ret.file, "-Wnone"]
     b = os.path.splitext(parse_ret.file)[0]
     if os.path.exists(b + ".cmd"):
-        with open(b + ".cmd", 'rU') as cmd_file:
+        with open(b + ".cmd", 'r') as cmd_file:
             for x in cmd_file:
                 args.extend(x.strip().split())
     args.extend(extra_argv)
@@ -134,7 +134,7 @@ if parse_ret.action == "run":
         for f in sorted(files):
             if f.endswith(".lp"):
                 b = os.path.join(root, f[:-3])
-                with open(b + ".lp", 'rU', encoding='utf-8') as inst_file:
+                with open(b + ".lp", 'r', encoding='utf-8') as inst_file:
                     inst = inst_file.read()
                     if (not with_python and re.search(r"#script[ ]*\(python\)", inst)) or \
                        (not with_lua and re.search(r"#script[ ]*\(lua\)", inst)) or \
@@ -147,13 +147,13 @@ if parse_ret.action == "run":
 
                 args = [clingo, "0", b + ".lp", "-Wnone"]
                 if os.path.exists(b + ".cmd"):
-                    with open(b + ".cmd", 'rU') as cmd_file:
+                    with open(b + ".cmd", 'r') as cmd_file:
                         for x in cmd_file:
                             args.extend(x.strip().split())
                 args.extend(extra_argv)
                 out, err = sp.Popen(args, stderr=sp.PIPE, stdout=sp.PIPE, universal_newlines=True).communicate()
                 norm = normalize(out)
-                with open(b + ".sol", 'rU') as sol_file:
+                with open(b + ".sol", 'r') as sol_file:
                     sol  = reorder(sol_file.read())
                 if norm != sol:
                     failed+= 1