@@ -70,20 +70,14 @@ def _maybe_compile(compiler, source, filename, symbol):
70
70
return None
71
71
# fallthrough
72
72
73
- return compiler (source , filename , symbol )
73
+ return compiler (source , filename , symbol , incomplete_input = False )
74
74
75
-
76
- def _is_syntax_error (err1 , err2 ):
77
- rep1 = repr (err1 )
78
- rep2 = repr (err2 )
79
- if "was never closed" in rep1 and "was never closed" in rep2 :
80
- return False
81
- if rep1 == rep2 :
82
- return True
83
- return False
84
-
85
- def _compile (source , filename , symbol ):
86
- return compile (source , filename , symbol , PyCF_DONT_IMPLY_DEDENT | PyCF_ALLOW_INCOMPLETE_INPUT )
75
+ def _compile (source , filename , symbol , incomplete_input = True ):
76
+ flags = 0
77
+ if incomplete_input :
78
+ flags |= PyCF_ALLOW_INCOMPLETE_INPUT
79
+ flags |= PyCF_DONT_IMPLY_DEDENT
80
+ return compile (source , filename , symbol , flags )
87
81
88
82
def compile_command (source , filename = "<input>" , symbol = "single" ):
89
83
r"""Compile a command and determine whether it is incomplete.
@@ -114,8 +108,12 @@ class Compile:
114
108
def __init__ (self ):
115
109
self .flags = PyCF_DONT_IMPLY_DEDENT | PyCF_ALLOW_INCOMPLETE_INPUT
116
110
117
- def __call__ (self , source , filename , symbol ):
118
- codeob = compile (source , filename , symbol , self .flags , True )
111
+ def __call__ (self , source , filename , symbol , ** kwargs ):
112
+ flags = self .flags
113
+ if kwargs .get ('incomplete_input' , True ) is False :
114
+ flags &= ~ PyCF_DONT_IMPLY_DEDENT
115
+ flags &= ~ PyCF_ALLOW_INCOMPLETE_INPUT
116
+ codeob = compile (source , filename , symbol , flags , True )
119
117
for feature in _features :
120
118
if codeob .co_flags & feature .compiler_flag :
121
119
self .flags |= feature .compiler_flag
0 commit comments