mirror of
https://github.com/python/cpython.git
synced 2025-11-01 14:11:41 +00:00
[3.13] gh-122546: Relax SyntaxError check when raising errors on the new REPL (GH-123233) (#123247)
gh-122546: Relax SyntaxError check when raising errors on the new REPL (GH-123233)
(cherry picked from commit 4c3f0cbeae)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
This commit is contained in:
parent
30eee22d3f
commit
fda8aec625
2 changed files with 5 additions and 1 deletions
|
|
@ -110,7 +110,7 @@ def showsyntaxerror(self, filename=None, **kwargs):
|
||||||
colorize = kwargs.pop('colorize', False)
|
colorize = kwargs.pop('colorize', False)
|
||||||
try:
|
try:
|
||||||
typ, value, tb = sys.exc_info()
|
typ, value, tb = sys.exc_info()
|
||||||
if filename and typ is SyntaxError:
|
if filename and issubclass(typ, SyntaxError):
|
||||||
value.filename = filename
|
value.filename = filename
|
||||||
source = kwargs.pop('source', "")
|
source = kwargs.pop('source', "")
|
||||||
self._showtraceback(typ, value, None, colorize, source)
|
self._showtraceback(typ, value, None, colorize, source)
|
||||||
|
|
|
||||||
|
|
@ -1109,6 +1109,10 @@ def test_correct_filename_in_syntaxerrors(self):
|
||||||
self.skipTest("pyrepl not available")
|
self.skipTest("pyrepl not available")
|
||||||
self.assertIn("SyntaxError: invalid syntax", output)
|
self.assertIn("SyntaxError: invalid syntax", output)
|
||||||
self.assertIn("<python-input-0>", output)
|
self.assertIn("<python-input-0>", output)
|
||||||
|
commands = " b\nexit()\n"
|
||||||
|
output, exit_code = self.run_repl(commands, env=env)
|
||||||
|
self.assertIn("IndentationError: unexpected indent", output)
|
||||||
|
self.assertIn("<python-input-0>", output)
|
||||||
|
|
||||||
def run_repl(
|
def run_repl(
|
||||||
self,
|
self,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue