-
Notifications
You must be signed in to change notification settings - Fork 291
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
WIP Python 3.12 support for removal of imp module #626
Conversation
@sfdye This is really blocking the use of future in Python 3.12, any plans up update it in Python 3.12? # 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 |
try: | ||
import importlib | ||
except ImportError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that
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.
import imp | ||
imp.reload(imp) | ||
self.assertTrue(True) | ||
except ImportError: | ||
import importlib | ||
importlib.reload(importlib) | ||
self.assertTrue(True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
I have a couple more commits that fix |
There was a problem hiding this 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.
try: | ||
import imp | ||
except ImportError: | ||
import importlib |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue #625
Test suite is broken.
src/past/translation/init.py is broken (I only replaced the import statement).