@@ -1848,29 +1848,9 @@ def _complete_statement(self, line: str) -> Statement:
18481848 # if we get here we must have:
18491849 # - a multiline command with no terminator
18501850 # - a multiline command with unclosed quotation marks
1851- if not self .quit_on_sigint :
1852- try :
1853- self .at_continuation_prompt = True
1854- newline = self .pseudo_raw_input (self .continuation_prompt )
1855- if newline == 'eof' :
1856- # they entered either a blank line, or we hit an EOF
1857- # for some other reason. Turn the literal 'eof'
1858- # into a blank line, which serves as a command
1859- # terminator
1860- newline = '\n '
1861- self .poutput (newline )
1862- line = '{}\n {}' .format (statement .raw , newline )
1863- except KeyboardInterrupt :
1864- self .poutput ('^C' )
1865- statement = self .statement_parser .parse ('' )
1866- break
1867- finally :
1868- self .at_continuation_prompt = False
1869- else :
1851+ try :
18701852 self .at_continuation_prompt = True
18711853 newline = self .pseudo_raw_input (self .continuation_prompt )
1872- self .at_continuation_prompt = False
1873-
18741854 if newline == 'eof' :
18751855 # they entered either a blank line, or we hit an EOF
18761856 # for some other reason. Turn the literal 'eof'
@@ -1879,6 +1859,15 @@ def _complete_statement(self, line: str) -> Statement:
18791859 newline = '\n '
18801860 self .poutput (newline )
18811861 line = '{}\n {}' .format (statement .raw , newline )
1862+ except KeyboardInterrupt as ex :
1863+ if self .quit_on_sigint :
1864+ raise ex
1865+ else :
1866+ self .poutput ('^C' )
1867+ statement = self .statement_parser .parse ('' )
1868+ break
1869+ finally :
1870+ self .at_continuation_prompt = False
18821871
18831872 if not statement .command :
18841873 raise EmptyStatement ()
@@ -2189,14 +2178,14 @@ def _cmdloop(self) -> bool:
21892178 self .poutput ('{}{}' .format (self .prompt , line ))
21902179 else :
21912180 # Otherwise, read a command from stdin
2192- if not self .quit_on_sigint :
2193- try :
2194- line = self .pseudo_raw_input (self .prompt )
2195- except KeyboardInterrupt :
2181+ try :
2182+ line = self .pseudo_raw_input (self .prompt )
2183+ except KeyboardInterrupt as ex :
2184+ if self .quit_on_sigint :
2185+ raise ex
2186+ else :
21962187 self .poutput ('^C' )
21972188 line = ''
2198- else :
2199- line = self .pseudo_raw_input (self .prompt )
22002189
22012190 # Run the command along with all associated pre and post hooks
22022191 stop = self .onecmd_plus_hooks (line )
0 commit comments