@@ -70,8 +70,7 @@ def _maybe_compile(compiler, source, filename, symbol):
70
70
return None
71
71
# fallthrough
72
72
73
- return compiler (source , filename , symbol )
74
-
73
+ return compiler (source , filename , symbol , incomplete_input = False )
75
74
76
75
def _is_syntax_error (err1 , err2 ):
77
76
rep1 = repr (err1 )
@@ -82,8 +81,12 @@ def _is_syntax_error(err1, err2):
82
81
return True
83
82
return False
84
83
85
- def _compile (source , filename , symbol ):
86
- return compile (source , filename , symbol , PyCF_DONT_IMPLY_DEDENT | PyCF_ALLOW_INCOMPLETE_INPUT )
84
+ def _compile (source , filename , symbol , incomplete_input = True ):
85
+ flags = 0
86
+ if incomplete_input :
87
+ flags |= PyCF_ALLOW_INCOMPLETE_INPUT
88
+ flags |= PyCF_DONT_IMPLY_DEDENT
89
+ return compile (source , filename , symbol , flags )
87
90
88
91
def compile_command (source , filename = "<input>" , symbol = "single" ):
89
92
r"""Compile a command and determine whether it is incomplete.
@@ -114,8 +117,12 @@ class Compile:
114
117
def __init__ (self ):
115
118
self .flags = PyCF_DONT_IMPLY_DEDENT | PyCF_ALLOW_INCOMPLETE_INPUT
116
119
117
- def __call__ (self , source , filename , symbol ):
118
- codeob = compile (source , filename , symbol , self .flags , True )
120
+ def __call__ (self , source , filename , symbol , ** kwargs ):
121
+ flags = self .flags
122
+ if kwargs .get ('incomplete_input' , True ) is False :
123
+ flags &= ~ PyCF_DONT_IMPLY_DEDENT
124
+ flags &= ~ PyCF_ALLOW_INCOMPLETE_INPUT
125
+ codeob = compile (source , filename , symbol , flags , True )
119
126
for feature in _features :
120
127
if codeob .co_flags & feature .compiler_flag :
121
128
self .flags |= feature .compiler_flag
0 commit comments