[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] fix unable to load *.pyd files with Python 3.8.x on Windows

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Sun, 10 May 2020 15:57:16 +0000

Jun Omae wrote on Sun, 10 May 2020 13:27 +0900:
> +++ subversion/bindings/swig/include/svn_global.swg (working copy)
> @@ -242,3 +242,40 @@
> +#ifdef SWIGPYTHON
> +/* Since Python 3.8+ on Windows, DLL dependencies when loading *.pyd file
> + * searches only the system paths, the directory containing the *.pyd file and
> + * the directories added with os.add_dll_directory().
> + * See also https://bugs.python.org/issue36085.
> + */
> +%define SVN_PYTHON_MODULEIMPORT
> +"
> +def _dll_paths():
> + import os
> + if hasattr(os, 'add_dll_directory'): # Python 3.8+ on Windows
> + cookies = []
> + for path in os.environ.get('PATH', '').split(';'):

Use os.pathsep in the split() call? That would make the code
self-documenting and be forward compatible with… well, with anything
that implements os.add_dll_directory() and uses another value of
os.pathsep. I guess Cygwin's Python package might fit this bill.

> + if path and os.path.isabs(path):
> + try:
> + cookie = os.add_dll_directory(path)
> + except:
> + continue

Should this really catch _all_ exceptions?

> + else:
> + cookies.append(cookie)
> + return cookies
> + else:
> + return ()

Cheers,

Daniel
Received on 2020-05-10 17:57:33 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.