Introspection test: Reverse os.add_dll_directory() order
authorChun-wei Fan <fanchunwei@src.gnome.org>
Tue, 26 Apr 2022 03:19:16 +0000 (11:19 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Tue, 26 Apr 2022 03:52:31 +0000 (11:52 +0800)
It looks like os.add_dll_directory() works in a LIFO order, so we call
os.add_dll_directory() from the end of the list of directories in %PATH%
so that the directories are searched in the correct order.

testsuite/introspection/api.py

index a0afd6be574d8cb7d98a31db3edfc513ed7596c4..a2feac37ea6fd2c905556bc1633e715ef2972e47 100755 (executable)
@@ -9,7 +9,7 @@ import sys
 # be loaded successfully by Python.  Make things easiler for people
 # by calling os.add_dll_directory() on the valid paths in %PATH%.
 if hasattr(os, 'add_dll_directory'):
-    paths = os.environ['PATH'].split(os.pathsep)
+    paths = reversed(os.environ['PATH'].split(os.pathsep))
     for path in paths:
         if path != '' and os.path.isdir(path):
             os.add_dll_directory(path)