GeezerVison is showing github.com — [3.13] gh-122546: Relax SyntaxError check when raising errors on the … · python/cpython@fda8aec
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: Lib/code.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -110,7 +110,7 @@ def showsyntaxerror(self, filename=None, **kwargs): |
110 | 110 | colorize = kwargs.pop('colorize', False) |
111 | 111 | try: |
112 | 112 | typ, value, tb = sys.exc_info() |
113 | | - if filename and typ is SyntaxError: |
| 113 | + if filename and issubclass(typ, SyntaxError): |
114 | 114 | value.filename = filename |
115 | 115 | source = kwargs.pop('source', "") |
116 | 116 | self._showtraceback(typ, value, None, colorize, source) |
|
Collapse file
Copy file name to clipboardExpand all lines: Lib/test/test_pyrepl/test_pyrepl.py +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1109,6 +1109,10 @@ def test_correct_filename_in_syntaxerrors(self): |
1109 | 1109 | self.skipTest("pyrepl not available") |
1110 | 1110 | self.assertIn("SyntaxError: invalid syntax", output) |
1111 | 1111 | self.assertIn("<python-input-0>", output) |
| 1112 | + commands = " b\nexit()\n" |
| 1113 | + output, exit_code = self.run_repl(commands, env=env) |
| 1114 | + self.assertIn("IndentationError: unexpected indent", output) |
| 1115 | + self.assertIn("<python-input-0>", output) |
1112 | 1116 |
|
1113 | 1117 | def run_repl( |
1114 | 1118 | self, |
|