Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Python 3.12 support for removal of imp module #626

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

odie5533
Copy link
Contributor

@odie5533 odie5533 commented Oct 11, 2023

Issue #625

Test suite is broken.

src/past/translation/init.py is broken (I only replaced the import statement).

======================================================================================= short test summary info ========================================================================================
FAILED tests/test_future/test_backports.py::TestOrderedDict::test_repr - AssertionError: "OrderedDict({'c': 1, 'b': 2, 'a': 3, 'd': 4, 'e': 5, 'f': 6})" != "OrderedDict([('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)])"
FAILED tests/test_future/test_backports.py::TestOrderedDict::test_repr_recursive - AssertionError: "OrderedDict({'a': None, 'b': None, 'c': None, 'x': ...})" != "OrderedDict([('a', None), ('b', None), ('c', None), ('x', ...)])"
FAILED tests/test_future/test_builtins.py::BuiltinTest::test_compile - SyntaxError: source code string cannot contain null bytes
FAILED tests/test_future/test_builtins.py::BuiltinTest::test_pow - AssertionError: (<class 'TypeError'>, <class 'ValueError'>) not raised by pow
FAILED tests/test_future/test_isinstance.py::TestIsInstanceIsSubclass::test_isinstance_recursion_limit - AssertionError: RuntimeError not raised by blowstack
FAILED tests/test_future/test_isinstance.py::TestIsInstanceIsSubclass::test_subclass_recursion_limit - AssertionError: RuntimeError not raised by blowstack
FAILED tests/test_future/test_standard_library.py::TestStandardLibraryReorganization::test_underscore_prefixed_modules - ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
FAILED tests/test_future/test_standard_library.py::TestFutureMoves::test_future_moves - ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
FAILED tests/test_future/test_urllib2.py::HandlerTests::test_ftp - AssertionError: None != 'image/gif'
FAILED tests/test_future/test_urllib2.py::test_main - future.backports.test.support.TestFailed: Traceback (most recent call last):
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_FileTests::test_close - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_FileTests::test_fileno - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_FileTests::test_getcode - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_FileTests::test_geturl - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_FileTests::test_info - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_FileTests::test_interface - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_FileTests::test_iter - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_FileTests::test_read - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_FileTests::test_readline - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_FileTests::test_readlines - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_FileTests::test_relativelocalfile - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::ProxyTests::test_getproxies_environment_keep_no_proxies - AttributeError: module 'future.moves.test.support' has no attribute 'EnvironmentVarGuard'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_HttpTests::test_URLopener_deprecation - AttributeError: module 'future.moves.test.support' has no attribute 'check_warnings'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_HttpTests::test_empty_socket - AttributeError: module 'future.moves.test.support' has no attribute 'check_warnings'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_HttpTests::test_file_notexists - AttributeError: module 'future.moves.test.support' has no attribute 'check_warnings'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_HttpTests::test_ftp_nohost - AttributeError: module 'future.moves.test.support' has no attribute 'check_warnings'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_HttpTests::test_ftp_nonexisting - AttributeError: module 'future.moves.test.support' has no attribute 'check_warnings'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_HttpTests::test_missing_localfile - AttributeError: module 'future.moves.test.support' has no attribute 'check_warnings'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_HttpTests::test_read_0_9 - AttributeError: module 'future.moves.test.support' has no attribute 'check_warnings'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_HttpTests::test_read_1_0 - AttributeError: module 'future.moves.test.support' has no attribute 'check_warnings'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_HttpTests::test_read_1_1 - AttributeError: module 'future.moves.test.support' has no attribute 'check_warnings'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_HttpTests::test_read_bogus - AttributeError: module 'future.moves.test.support' has no attribute 'check_warnings'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_HttpTests::test_userpass_inurl - AttributeError: module 'future.moves.test.support' has no attribute 'check_warnings'
FAILED tests/test_future/test_urllib_toplevel.py::urlopen_HttpTests::test_userpass_inurl_w_spaces - AttributeError: module 'future.moves.test.support' has no attribute 'check_warnings'
FAILED tests/test_future/test_urllib_toplevel.py::urlretrieve_FileTests::test_basic - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::urlretrieve_FileTests::test_copy - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::urlretrieve_FileTests::test_reporthook - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::urlretrieve_FileTests::test_reporthook_0_bytes - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::urlretrieve_FileTests::test_reporthook_5_bytes - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::urlretrieve_FileTests::test_reporthook_8193_bytes - AttributeError: module 'future.moves.test.support' has no attribute 'TESTFN'
FAILED tests/test_future/test_urllib_toplevel.py::UnquotingTests::test_unquoting - AttributeError: module 'future.moves.test.support' has no attribute 'check_warnings'
FAILED tests/test_future/test_urllib_toplevel.py::URLopener_Tests::test_quoted_open - AttributeError: module 'future.moves.test.support' has no attribute 'check_warnings'
FAILED tests/test_future/test_utils.py::TestUtils::test_raise_ - AttributeError: 'TestUtils' object has no attribute 'assertRaisesRegexp'. Did you mean: 'assertRaisesRegex'?
FAILED tests/test_past/test_translation.py::TestTranslate::test_div - AssertionError: 1.5 != 1
FAILED tests/test_past/test_translation.py::TestTranslate::test_exception_syntax - AttributeError: 'NoneType' object has no attribute 'value'
FAILED tests/test_past/test_translation.py::TestTranslate::test_exec_statement - AttributeError: 'NoneType' object has no attribute 'x'
FAILED tests/test_past/test_translation.py::TestTranslate::test_old_builtin_functions - NameError: name 'xrange' is not defined
FAILED tests/test_past/test_translation.py::TestTranslate::test_print_statement - AttributeError: 'NoneType' object has no attribute 'finished'
FAILED tests/test_past/test_translation.py::TestTranslate::test_xrange - NameError: name 'xrange' is not defined
================================================================ 49 failed, 1010 passed, 37 skipped, 46 xfailed, 70 warnings in 23.56s =================================================================

@bernhardkaindl
Copy link

@sfdye This is really blocking the use of future in Python 3.12, any plans up update it in Python 3.12?
For others users: For now, instead of:

# pylint: disable=wrong-import-position,wrong-import-order
from future import standard_library
standard_library.install_aliases()

We now just use this to have Python2 code working for Python2 and Python3:

try:
    import xmlrpclib
    import SocketServer
    import SimpleXMLRPCServer
except:
    import xmlrpc.client as xmlrpclib
    import socketserver as SocketServer
    import xmlrpc.server as SimpleXMLRPCServer

Comment on lines +65 to +67
try:
import importlib
except ImportError:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that

Suggested change
try:
import importlib
except ImportError:
if PY2:

and moving the block after from future.utils import PY2, PY3 should be enough (i.e. no change needed to _find_and_load_module()), since the RenameImport class is only instantiated under Python2.

Comment on lines +451 to +457
import imp
imp.reload(imp)
self.assertTrue(True)
except ImportError:
import importlib
importlib.reload(importlib)
self.assertTrue(True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import imp
imp.reload(imp)
self.assertTrue(True)
except ImportError:
import importlib
importlib.reload(importlib)
self.assertTrue(True)
import importlib
importlib.reload(importlib)
except ImportError:
import imp
imp.reload(imp)
self.assertTrue(True)

@nsoranzo
Copy link
Contributor

Issue #625

Test suite is broken.

src/past/translation/__init__.py is broken (I only replaced the import statement).

I have a couple more commits that fix src/past/translation/__init__.py and a bunch of tests at https://github.com/nsoranzo/python-future/tree/python312-imp-module_past , if anyone is interested.

Copy link

@aij aij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this! I'm not on 3.12 yet but I came across this while wondering if there was an upstream fix for the imp deprecation warnings.

Comment on lines +35 to +38
try:
import imp
except ImportError:
import importlib
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When both modules are available, it would be better to prefer importlib to avoid logging deprecation warnings from imp.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aij Have a look at #632 .

@nsoranzo nsoranzo mentioned this pull request Feb 1, 2024
@edschofield edschofield merged commit a6222d2 into PythonCharmers:master Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants