Skip to content

Excessive exception traces with Pythonwin.exe v307 #2393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SukramLeinad opened this issue Oct 12, 2024 · 6 comments
Closed

Excessive exception traces with Pythonwin.exe v307 #2393

SukramLeinad opened this issue Oct 12, 2024 · 6 comments

Comments

@SukramLeinad
Copy link

Steps to reproduce the problem

Open the Pythonwin.exe and type

c := 3

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(
~~~~~~~~~~~~~~~~~~~~~^
source, ""
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
): # Need more input!
^
File "C:\Program Files\Python313\Lib\code.py", line 68, in runsource
self.showsyntaxerror(filename, source=source)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: PythonwinInteractiveInterpreter.showsyntaxerror() got an unexpected keyword argument 'source'

System information

Python version and distribution:
PythonWin 3.13.0 (tags/v3.13.0:60403a5, Oct 7 2024, 09:38:07) [MSC v.1941 64 bit (AMD64)] on win32.

pywin32 version:
307, installed with pip

Windows Version:
Win 10 with local admin account

DLL locations:
C:\Program Files\Python313\Lib\site-packages\pywin32_system32\pywintypes313.dll
C:\Program Files\Python313\Lib\site-packages\pywin32_system32\pythoncom313.dll

@mhammond
Copy link
Owner

mhammond commented Oct 12, 2024

I think this line should change to def showsyntaxerror(self, filename=None, **kwargs): - are you able to check that fixes things?

@SukramLeinad
Copy link
Author

Thank you very much! I have applied your fix locally and the behavior is now correct.

@mhammond
Copy link
Owner

Fixed by #2394

@SukramLeinad
Copy link
Author

SukramLeinad commented Oct 12, 2024

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 python/cpython#125380

@SukramLeinad
Copy link
Author

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.

@mhammond
Copy link
Owner

Thanks! Feel free to open a new issue here for further improvements!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants