This is an automated email from the ASF dual-hosted git repository.

chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fury.git


The following commit(s) were added to refs/heads/main by this push:
     new c578cb2f chore(py314): Replace deprecated pkgutil.find_loader (#1888)
c578cb2f is described below

commit c578cb2fdd3e7fa87f0802afc126219a568f3e1e
Author: Chris Markiewicz <[email protected]>
AuthorDate: Wed Oct 16 22:29:29 2024 -0400

    chore(py314): Replace deprecated pkgutil.find_loader (#1888)
    
    This PR removes [pkgutil.find_loader()][] and replaces it with
    [importlib.util.find_spec()][]. `find_loader` was deprecated in Python
    3.12 and will be removed in 3.14. `find_spec` has been present since
    Python 3.4.
    
    Both functions return `None` if the module loader cannot be found. For
    its use in this project, this is sufficient and no translation of the
    return value is needed.
    
    [pkgutil.find_loader()]:
    https://docs.python.org/3/library/pkgutil.html#pkgutil.get_loader
    [importlib.util.find_spec()]:
    https://docs.python.org/3/library/importlib.html#importlib.util.find_spec
---
 python/pyfury/util.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/python/pyfury/util.py b/python/pyfury/util.py
index b4a5a96b..a8d6cf7d 100644
--- a/python/pyfury/util.py
+++ b/python/pyfury/util.py
@@ -17,7 +17,6 @@
 
 import importlib
 import inspect
-import pkgutil
 import sys
 from typing import Dict, Callable
 
@@ -61,7 +60,7 @@ def lazy_import(
             self._on_loads.append(func)
             return func
 
-    if pkgutil.find_loader(prefix_name) is not None:
+    if importlib.util.find_spec(prefix_name) is not None:
         return LazyModule()
     elif placeholder:
         return ModulePlaceholder(prefix_name)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to