diff --git a/build.sh b/build.sh index df1f00f7..ef52cb41 100755 --- a/build.sh +++ b/build.sh @@ -3,7 +3,7 @@ set -xuo pipefail DOCKER_IMAGE=jmadler/python-future-builder # XXX: TODO: Perhaps this version shouldn't be hardcoded -version=0.18.3 +version=0.18.4 docker build . -t $DOCKER_IMAGE docker push $DOCKER_IMAGE:latest diff --git a/docs/whatsnew.rst b/docs/whatsnew.rst index 40f7191f..9018fdfe 100644 --- a/docs/whatsnew.rst +++ b/docs/whatsnew.rst @@ -3,6 +3,12 @@ What's New ********** +What's new in version 0.18.4 (2023-10-10) +========================================= +This is a minor bug-fix release containing a number of fixes: + +- Fix for Python 3.12's removal of the imp module + What's new in version 0.18.3 (2023-01-13) ========================================= This is a minor bug-fix release containing a number of fixes: diff --git a/src/future/__init__.py b/src/future/__init__.py index b609299a..64b66f43 100644 --- a/src/future/__init__.py +++ b/src/future/__init__.py @@ -87,7 +87,7 @@ __copyright__ = 'Copyright 2013-2019 Python Charmers Pty Ltd' __ver_major__ = 0 __ver_minor__ = 18 -__ver_patch__ = 3 +__ver_patch__ = 4 __ver_sub__ = '' __version__ = "%d.%d.%d%s" % (__ver_major__, __ver_minor__, __ver_patch__, __ver_sub__) diff --git a/src/future/backports/test/support.py b/src/future/backports/test/support.py index 1999e208..08b59829 100644 --- a/src/future/backports/test/support.py +++ b/src/future/backports/test/support.py @@ -28,7 +28,10 @@ # import collections.abc # not present on Py2.7 import re import subprocess -import imp +try: + from imp import cache_from_source +except ImportError: + from importlib.util import cache_from_source import time try: import sysconfig @@ -351,7 +354,7 @@ def make_legacy_pyc(source): does not need to exist, however the PEP 3147 pyc file must exist. :return: The file system path to the legacy pyc file. """ - pyc_file = imp.cache_from_source(source) + pyc_file = cache_from_source(source) up_one = os.path.dirname(os.path.abspath(source)) legacy_pyc = os.path.join(up_one, source + ('c' if __debug__ else 'o')) os.rename(pyc_file, legacy_pyc) @@ -370,8 +373,8 @@ def forget(modname): # combinations of PEP 3147 and legacy pyc and pyo files. unlink(source + 'c') unlink(source + 'o') - unlink(imp.cache_from_source(source, debug_override=True)) - unlink(imp.cache_from_source(source, debug_override=False)) + unlink(cache_from_source(source, debug_override=True)) + unlink(cache_from_source(source, debug_override=False)) # On some platforms, should not run gui test even if it is allowed # in `use_resources'. diff --git a/src/future/standard_library/__init__.py b/src/future/standard_library/__init__.py index cff02f95..24d9287f 100644 --- a/src/future/standard_library/__init__.py +++ b/src/future/standard_library/__init__.py @@ -62,7 +62,10 @@ import sys import logging -import imp +try: + import importlib +except ImportError: + import imp import contextlib import types import copy @@ -297,8 +300,11 @@ def _find_and_load_module(self, name, path=None): flog.debug('What to do here?') name = bits[0] - module_info = imp.find_module(name, path) - return imp.load_module(name, *module_info) + try: + module_info = imp.find_module(name, path) + return imp.load_module(name, *module_info) + except AttributeError: + return importlib.import_module(name, path) class hooks(object): diff --git a/src/past/translation/__init__.py b/src/past/translation/__init__.py index 7c678866..6e6ccf74 100644 --- a/src/past/translation/__init__.py +++ b/src/past/translation/__init__.py @@ -32,7 +32,10 @@ Inspired by and based on ``uprefix`` by Vinay M. Sajip. """ -import imp +try: + import imp +except ImportError: + import importlib import logging import marshal import os diff --git a/tests/test_future/test_standard_library.py b/tests/test_future/test_standard_library.py index 3ac5d2d7..f3477210 100644 --- a/tests/test_future/test_standard_library.py +++ b/tests/test_future/test_standard_library.py @@ -447,9 +447,14 @@ def test_reload(self): """ reload has been moved to the imp module """ - import imp - imp.reload(imp) - self.assertTrue(True) + try: + import imp + imp.reload(imp) + self.assertTrue(True) + except ImportError: + import importlib + importlib.reload(importlib) + self.assertTrue(True) def test_install_aliases(self): """