mhammond / pywin32

Python for Windows (pywin32) Extensions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pythonwin interactive window now gets tracebacks with python3.12, probably 3.11 too...

zarquon5 opened this issue · comments

Expected behavior and actual behavior

When you start typing a function call in the interactive window of Pythonwin, it used to give you a "CallTip" that indicated the arguments to the function in question. Hoewever, the CallTips mechanism no longer works because it depends on a function, inspect.formatargspec(), that has apparently been deprecated since python 3.5, and removed in python 3.11. (See python/cpython#28618.)

This makes using the pythonwin interactive window very problematic.

Steps to reproduce the problem

  1. Open pythonwin 3.12.1
>>> import os
>>> os.path.join(

As soon as you hit the (, you get the traceback:

>>> Failed to format the args
Traceback (most recent call last):
  File "c:\ProgramData\conda\envs\myenv\lib\site-packages\pythonwin\pywin\idle\CallTips.py", line 133, in get_arg_text
    argText = inspect.formatargspec(*inspect.getfullargspec(fob))
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'inspect' has no attribute 'formatargspec'. Did you mean: 'formatargvalues'?

(see GrahamDumpleton/wrapt#196 for a similar issue with wrapt that was then fixed.)

System information

Python version and distribution: 3.12.1, miniconda3.
pywin32 version: 305.1
Installed from PyPI

Windows Version: 10.0.17763 Build 17763

DLL locations:
c:\ProgramData\conda\envs\myenv\Lib\site-packages\pywin32_system32\pywintypes312.dll
c:\ProgramData\conda\envs\myenv\Lib\site-packages\pywin32_system32\pythoncom312.dll

Hi @zarquon5 , could you try with pywin32==306 ? This should already have been fixed by #1975

formatargspec isn't used anywhere in the codebase anymore.