[geany/www.geany.org] 42fe19: Replace deprecated 'imp' module by 'importlib'

Enrico Tröger git-noreply at xxxxx
Thu Jun 20 10:38:30 UTC 2019


Branch:      refs/heads/master
Author:      Enrico Tröger <enrico.troeger at uvena.de>
Committer:   Enrico Tröger <enrico.troeger at uvena.de>
Date:        Thu, 20 Jun 2019 10:38:30 UTC
Commit:      42fe1997b5bb55a1156d2d76b47bd66cd5600b0f
             https://github.com/geany/www.geany.org/commit/42fe1997b5bb55a1156d2d76b47bd66cd5600b0f

Log Message:
-----------
Replace deprecated 'imp' module by 'importlib'


Modified Paths:
--------------
    geany/settings.py

Modified: geany/settings.py
6 lines changed, 3 insertions(+), 3 deletions(-)
===================================================================
@@ -600,10 +600,10 @@
 filename = os.path.join(PROJECT_APP_PATH, 'local_settings.py')  # pylint: disable=invalid-name
 if os.path.exists(filename):
     import sys
-    import imp
+    from importlib.util import module_from_spec, spec_from_file_location
     module_name = '{}.local_settings'.format(PROJECT_APP)  # pylint: disable=invalid-name
-    module = imp.new_module(module_name)  # pylint: disable=invalid-name
-    module.__file__ = filename
+    spec = spec_from_file_location(module_name, filename)  # pylint: disable=invalid-name
+    module = module_from_spec(spec)  # pylint: disable=invalid-name
     sys.modules[module_name] = module
     exec(open(filename, 'rb').read())  # pylint: disable=exec-used
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list