[glib: 3/16] tests: Fix gengiotypefuncs.py helper script




commit 8dde15a5b328e370a8d28ddfda065d103db1dee9
Author: Philip Withnall <pwithnall endlessos org>
Date:   Tue Jun 14 15:20:39 2022 +0100

    tests: Fix gengiotypefuncs.py helper script
    
    It seems this script has potentially never worked properly under Python
    3. It’s supposed to list all the `_get_type()` functions it can find in
    the GIO headers, but since the regex string passed to `re.search()` was
    not a Python regex, nothing was matching.
    
    Fix that, and do another few small cleanups to the script.
    
    This makes the `defaultvalue` test not skip all the types.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 gio/tests/gengiotypefuncs.py | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/gio/tests/gengiotypefuncs.py b/gio/tests/gengiotypefuncs.py
index dbd8195e74..ab99df66ae 100644
--- a/gio/tests/gengiotypefuncs.py
+++ b/gio/tests/gengiotypefuncs.py
@@ -25,10 +25,9 @@ for filename in in_files:
     with open(filename, "rb") as f:
         for line in f:
             line = line.rstrip(b"\n").rstrip(b"\r")
-            # print line
-            match = re.search(b"\bg_[a-zA-Z0-9_]*_get_type\b", line)
+            match = re.search(br"\bg_[a-zA-Z0-9_]*_get_type\b", line)
             if match:
-                func = match.group(0)
+                func = match.group(0).decode('utf-8')
                 if func not in funcs:
                     funcs.append(func)
                     if debug:
@@ -38,10 +37,23 @@ file_output = "G_GNUC_BEGIN_IGNORE_DEPRECATIONS\n"
 
 funcs = sorted(funcs)
 
+# These types generally emit critical warnings if constructed in the wrong
+# environment (for example, without D-Bus running), so skip them.
+ignored_types = [
+    "g_io_extension_get_type",
+    "g_settings_backend_get_type",
+    "g_debug_controller_dbus_get_type",
+    "g_file_icon_get_type",
+    "g_unix_credentials_message_get_type",
+    "g_unix_socket_address_get_type",
+]
+
 for f in funcs:
-    if f not in ["g_io_extension_get_type", "g_settings_backend_get_type"]:
+    if f not in ignored_types:
         file_output += "*tp++ = {0} ();\n".format(f)
 
+file_output += "G_GNUC_END_IGNORE_DEPRECATIONS\n"
+
 if debug:
     print(len(funcs), "functions")
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]