Files
macports-ports/python/thefuck/files/patch-python312.diff
2024-01-08 13:22:16 -05:00

42 lines
1.1 KiB
Diff

diff --git a/thefuck/conf.py b/thefuck/conf.py
index 27876ef47..611ec84b7 100644
--- a/thefuck/conf.py
+++ b/thefuck/conf.py
@@ -1,4 +1,3 @@
-from imp import load_source
import os
import sys
from warnings import warn
@@ -6,6 +5,17 @@
from . import const
from .system import Path
+try:
+ import importlib.util
+
+ def load_source(name, pathname, _file=None):
+ module_spec = importlib.util.spec_from_file_location(name, pathname)
+ module = importlib.util.module_from_spec(module_spec)
+ module_spec.loader.exec_module(module)
+ return module
+except ImportError:
+ from imp import load_source
+
class Settings(dict):
def __getattr__(self, item):
diff --git a/thefuck/types.py b/thefuck/types.py
index 96e6ace67..b3b64c35d 100644
--- a/thefuck/types.py
+++ b/thefuck/types.py
@@ -1,9 +1,8 @@
-from imp import load_source
import os
import sys
from . import logs
from .shells import shell
-from .conf import settings
+from .conf import settings, load_source
from .const import DEFAULT_PRIORITY, ALL_ENABLED
from .exceptions import EmptyCommand
from .utils import get_alias, format_raw_script