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

Update imp to importlib for py3 #574

Merged
merged 3 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/other/auto2to3.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
import argparse
import os
import sys
import imp
# imp was deprecated in python 3.6
if sys.version_info >= (3, 6):
import importlib as imp
else:
import imp
import runpy
from io import StringIO
from pkgutil import ImpImporter, ImpLoader
Expand Down
6 changes: 5 additions & 1 deletion src/future/backports/test/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
# import collections.abc # not present on Py2.7
import re
import subprocess
import imp
# imp was deprecated in python 3.6
if sys.version_info >= (3, 6):
import importlib as imp
else:
import imp
import time
try:
import sysconfig
Expand Down
6 changes: 5 additions & 1 deletion src/future/standard_library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@

import sys
import logging
import imp
# imp was deprecated in python 3.6
if sys.version_info >= (3, 6):
import importlib as imp
else:
import imp
import contextlib
import types
import copy
Expand Down
7 changes: 6 additions & 1 deletion src/past/builtins/misc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import unicode_literals

import inspect
import sys

from future.utils import PY2, PY3, exec_

Expand Down Expand Up @@ -42,7 +43,11 @@ def oct(number):
return '0' + builtins.oct(number)[2:]

raw_input = input
from imp import reload
# imp was deprecated in python 3.6
if sys.version_info >= (3, 6):
from importlib import reload
else:
from imp import reload
unicode = str
unichr = chr
xrange = range
Expand Down
8 changes: 6 additions & 2 deletions src/past/translation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@
Inspired by and based on ``uprefix`` by Vinay M. Sajip.
"""

import imp
import sys
# imp was deprecated in python 3.6
if sys.version_info >= (3, 6):
import importlib as imp
else:
import imp
import logging
import marshal
import os
import sys
import copy
from lib2to3.pgen2.parse import ParseError
from lib2to3.refactor import RefactoringTool
Expand Down
6 changes: 5 additions & 1 deletion tests/test_future/test_standard_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,11 @@ def test_reload(self):
"""
reload has been moved to the imp module
"""
import imp
# imp was deprecated in python 3.6
if sys.version_info >= (3, 6):
import importlib as imp
else:
import imp
imp.reload(imp)
Copy link
Author

Choose a reason for hiding this comment

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

I wonder if this is causing the CI failure.

self.assertTrue(True)

Expand Down