mhammond / pywin32

Python for Windows (pywin32) Extensions
4.9k stars 783 forks source link

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

Closed zarquon5 closed 4 weeks ago

zarquon5 commented 2 months ago

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 https://github.com/python/cpython/pull/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 [https://github.com/GrahamDumpleton/wrapt/issues/196](https://github.com/GrahamDumpleton/wrapt/issues/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
Avasam commented 2 months ago

Hi @zarquon5 , could you try with pywin32==306 ? This should already have been fixed by https://github.com/mhammond/pywin32/pull/1975

formatargspec isn't used anywhere in the codebase anymore.

Avasam commented 4 weeks ago

I'll close as fixed by #1975 , please let us know if you still have issues with pywin32 version 306 or above