mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-31 07:04:12 +00:00 
			
		
		
		
	#1248: Use imp only when importlib.util not available
The imp module is deprecated and will be removed in Python 12.
This commit is contained in:
		
							
								
								
									
										2
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							| @@ -10,7 +10,7 @@ jobs: | |||||||
|     strategy: |     strategy: | ||||||
|       matrix: |       matrix: | ||||||
|         os: [ubuntu-latest, macos-latest, windows-latest] |         os: [ubuntu-latest, macos-latest, windows-latest] | ||||||
|         python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] |         python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"] | ||||||
|       fail-fast: false |       fail-fast: false | ||||||
|     runs-on: ${{ matrix.os }} |     runs-on: ${{ matrix.os }} | ||||||
|     steps: |     steps: | ||||||
|   | |||||||
| @@ -1,4 +1,3 @@ | |||||||
| from imp import load_source |  | ||||||
| import os | import os | ||||||
| import sys | import sys | ||||||
| from warnings import warn | from warnings import warn | ||||||
| @@ -6,6 +5,17 @@ from six import text_type | |||||||
| from . import const | from . import const | ||||||
| from .system import Path | 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): | class Settings(dict): | ||||||
|     def __getattr__(self, item): |     def __getattr__(self, item): | ||||||
|   | |||||||
| @@ -1,9 +1,8 @@ | |||||||
| from imp import load_source |  | ||||||
| import os | import os | ||||||
| import sys | import sys | ||||||
| from . import logs | from . import logs | ||||||
| from .shells import shell | from .shells import shell | ||||||
| from .conf import settings | from .conf import settings, load_source | ||||||
| from .const import DEFAULT_PRIORITY, ALL_ENABLED | from .const import DEFAULT_PRIORITY, ALL_ENABLED | ||||||
| from .exceptions import EmptyCommand | from .exceptions import EmptyCommand | ||||||
| from .utils import get_alias, format_raw_script | from .utils import get_alias, format_raw_script | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user