mirror of
https://anongit.gentoo.org/git/repo/gentoo.git
synced 2025-12-16 15:14:38 +00:00
42 lines
1.3 KiB
Diff
42 lines
1.3 KiB
Diff
From ed79b4b9f53fe99293139c18f053168e564508b8 Mon Sep 17 00:00:00 2001
|
|
From: wisp3rwind <17089248+wisp3rwind@users.noreply.github.com>
|
|
Date: Thu, 17 Apr 2025 22:35:06 +0200
|
|
Subject: [PATCH] address deprecation of pkgutil.get_loader
|
|
|
|
Closes https://github.com/beetbox/confuse/issues/165
|
|
---
|
|
confuse/util.py | 12 +++++++++---
|
|
1 file changed, 9 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/confuse/util.py b/confuse/util.py
|
|
index c27e161..a3f6e62 100644
|
|
--- a/confuse/util.py
|
|
+++ b/confuse/util.py
|
|
@@ -1,9 +1,9 @@
|
|
+import importlib.util
|
|
import os
|
|
import sys
|
|
import argparse
|
|
import optparse
|
|
import platform
|
|
-import pkgutil
|
|
|
|
|
|
UNIX_DIR_FALLBACK = '~/.config'
|
|
@@ -114,8 +114,14 @@ def find_package_path(name):
|
|
None if the path could not be identified (e.g., if
|
|
``name == "__main__"``).
|
|
"""
|
|
- # Based on get_root_path from Flask by Armin Ronacher.
|
|
- loader = pkgutil.get_loader(name)
|
|
+ # Based on get_root_path from Flask by Armin Ronacher, cf.
|
|
+ # https://github.com/pallets/flask/blob/85c5d93cbd049c4bd0679c36fd1ddcae8c37b642/src/flask/helpers.py#L570
|
|
+ try:
|
|
+ spec = importlib.util.find_spec(name)
|
|
+ except (ImportError, ValueError):
|
|
+ return None
|
|
+
|
|
+ loader = spec.loader
|
|
if loader is None or name == '__main__':
|
|
return None
|
|
|