Skip to content

Commit

Permalink
rf(py314): Replace deprecated pkgutil.find_loader (#3384)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
effigies authored Oct 16, 2024
2 parents 5d7a6d3 + bf38d9e commit 2e4f921
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fmriprep/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,9 +794,9 @@ def parse_args(args=None, namespace=None):
config.from_dict(vars(opts), init=['nipype'])

if not config.execution.notrack:
import pkgutil
import importlib.util

if pkgutil.find_loader('sentry_sdk') is None:
if importlib.util.find_spec('sentry_sdk') is None:
config.execution.notrack = True
config.loggers.cli.warning('Telemetry disabled because sentry_sdk is not installed.')
else:
Expand Down

0 comments on commit 2e4f921

Please sign in to comment.