Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cdf8209

Browse files
authored
Merge pull request #13327 from Carreau/less-37-II
More cleanup of pre-3.8 codepath
2 parents a9dac04 + 92cba8c commit cdf8209

3 files changed

Lines changed: 23 additions & 36 deletions

File tree

IPython/core/inputtransformer2.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,6 @@ def __init__(self, extra_flags=0):
791791
self.compiler = MaybeAsyncCompile(extra_flags=extra_flags)
792792

793793

794-
if (sys.version_info.major, sys.version_info.minor) >= (3, 8):
795-
_extra_flags = ast.PyCF_ALLOW_TOP_LEVEL_AWAIT
796-
else:
797-
_extra_flags = ast.PyCF_ONLY_AST
794+
_extra_flags = ast.PyCF_ALLOW_TOP_LEVEL_AWAIT
798795

799796
compile_command = MaybeAsyncCommandCompiler(extra_flags=_extra_flags)

IPython/core/magics/execution.py

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,44 @@
88
import ast
99
import bdb
1010
import builtins as builtin_mod
11+
import cProfile as profile
1112
import gc
1213
import itertools
14+
import math
1315
import os
16+
import pstats
17+
import re
1418
import shlex
1519
import sys
1620
import time
1721
import timeit
18-
import math
19-
import re
22+
from ast import Module
23+
from io import StringIO
24+
from logging import error
25+
from pathlib import Path
2026
from pdb import Restart
27+
from warnings import warn
2128

22-
import cProfile as profile
23-
import pstats
24-
25-
from IPython.core import oinspect
26-
from IPython.core import magic_arguments
27-
from IPython.core import page
29+
from IPython.core import magic_arguments, oinspect, page
2830
from IPython.core.error import UsageError
2931
from IPython.core.macro import Macro
30-
from IPython.core.magic import (Magics, magics_class, line_magic, cell_magic,
31-
line_cell_magic, on_off, needs_local_scope,
32-
no_var_expand)
32+
from IPython.core.magic import (
33+
Magics,
34+
cell_magic,
35+
line_cell_magic,
36+
line_magic,
37+
magics_class,
38+
needs_local_scope,
39+
no_var_expand,
40+
on_off,
41+
)
3342
from IPython.testing.skipdoctest import skip_doctest
34-
from IPython.utils.contexts import preserve_keys
3543
from IPython.utils.capture import capture_output
44+
from IPython.utils.contexts import preserve_keys
3645
from IPython.utils.ipstruct import Struct
3746
from IPython.utils.module_paths import find_mod
3847
from IPython.utils.path import get_py_filename, shellglob
3948
from IPython.utils.timing import clock, clock2
40-
from warnings import warn
41-
from logging import error
42-
from pathlib import Path
43-
from io import StringIO
44-
from pathlib import Path
45-
46-
if sys.version_info > (3,8):
47-
from ast import Module
48-
else :
49-
# mock the new API, ignore second argument
50-
# see https://github.com/ipython/ipython/issues/11590
51-
from ast import Module as OriginalModule
52-
Module = lambda nodelist, type_ignores: OriginalModule(nodelist)
53-
5449

5550
#-----------------------------------------------------------------------------
5651
# Magic implementation classes

IPython/core/tests/test_magic.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,12 +1308,7 @@ def test_time_no_var_expand():
13081308
# this is slow, put at the end for local testing.
13091309
def test_timeit_arguments():
13101310
"Test valid timeit arguments, should not cause SyntaxError (GH #1269)"
1311-
if sys.version_info < (3,7):
1312-
_ip.magic("timeit -n1 -r1 ('#')")
1313-
else:
1314-
# 3.7 optimize no-op statement like above out, and complain there is
1315-
# nothing in the for loop.
1316-
_ip.magic("timeit -n1 -r1 a=('#')")
1311+
_ip.magic("timeit -n1 -r1 a=('#')")
13171312

13181313

13191314
TEST_MODULE = """

0 commit comments

Comments
 (0)