Closed SukramLeinad closed 1 month ago
I think this line should change to def showsyntaxerror(self, filename=None, **kwargs):
- are you able to check that fixes things?
Thank you very much! I have applied your fix locally and the behavior is now correct.
Fixed by #2394
I noticed that the error statement is still somewhat mangled.
It reads:
Traceback ( File "<interactive input>", line 1
But i would expect this:
Traceback (most recent call last):
File "<interactive input>", line 1, in `<module>`
As CPython has a very similar defect, I raised https://github.com/python/cpython/issues/125380
About my last comment here:
CPython's method traceback.print_exception omits “Traceback (most recent call last):” for syntax errors as there is no traceback object. And there is no traceback object as code with syntax errors won’t compile and therefor can’t be executed.
Thanks! Feel free to open a new issue here for further improvements!
Steps to reproduce the problem
Open the Pythonwin.exe and type
Expected behavior (as per python.exe)
File "", line 1
c := 3
^^
SyntaxError: invalid syntax
Actual behavior
Firing event 'ProcessEnter' failed. Traceback (most recent call last): File "C:\Program Files\Python313\Lib\code.py", line 65, in runsource code = self.compile(source, filename, symbol) File "C:\Program Files\Python313\Lib\codeop.py", line 152, in call return _maybe_compile(self.compiler, source, filename, symbol) File "C:\Program Files\Python313\Lib\codeop.py", line 74, in _maybe_compile return compiler(source, filename, symbol, incomplete_input=False) File "C:\Program Files\Python313\Lib\codeop.py", line 117, in call codeob = compile(source, filename, symbol, flags, True) File "", line 1
c := 3
^^
SyntaxError: invalid syntax
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Program Files\Python313\Lib\site-packages\pythonwin\pywin\scintilla\bindings.py", line 148, in fire rc = binding.handler(*args) File "C:\Program Files\Python313\Lib\site-packages\pythonwin\pywin\framework\interact.py", line 565, in ProcessEnterEvent if self.interp.runsource(