Skip to content
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

Deprecation warning during text completion in REPL #113978

Closed
WolframAlph opened this issue Jan 12, 2024 · 3 comments
Closed

Deprecation warning during text completion in REPL #113978

WolframAlph opened this issue Jan 12, 2024 · 3 comments
Labels
topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error

Comments

@WolframAlph
Copy link
Contributor

WolframAlph commented Jan 12, 2024

Bug report

Bug description:

Define function inside REPL session:

>>> def f():pass

then try to hit TAB to get suggestions for f.__code__. and you will be left with this ugly output without suggestions:

>>> f.__code__./root/Desktop/cpython-main/Lib/rlcompleter.py:191: DeprecationWarning: co_lnotab is deprecated, use co_lines instead.
  if (value := getattr(thisobject, word, None)) is not None:

then try to access co_lnotab and you will get this warning again:

>>> f.__code__.co_lnotab
<stdin>-1:1: DeprecationWarning: co_lnotab is deprecated, use co_lines instead.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

@terryjreedy
Copy link
Member

IDLE's completer uses 'dir(ob)' to get the list of (22) attribute names, including 'co_lnotab'. dir does not access the objects themselves, hence no DeprecationWarning. This issue arises because rlcompleter accesses objects in order to add suffixes such as '(' or '()'. I added a note to the IDLE issue #113978 proposing to copy rlcompleter.

@gaogaotiantian
Copy link
Member

Are you on debug build? DeprecationWarning should be turned off on release build unless it's directly from __main__, so you should not be able to reproduce this on release build - let me know if you can.

If you can't do that, this is a much smaller issue. Personally, I don't hate warnings on debug mode. I am a bit hesitated to turn off all the warnings during text completion in REPL though.

@ambv
Copy link
Contributor

ambv commented May 21, 2024

Thanks! ✨ 🍰 ✨

@ambv ambv closed this as completed May 21, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 22, 2024
…onGH-113979)

(cherry picked from commit e03dde5)

Co-authored-by: Yan Yanchii <yyanchiy@gmail.com>
ambv pushed a commit that referenced this issue May 22, 2024
…113979) (#119429)

(cherry picked from commit e03dde5)

Co-authored-by: Yan Yanchii <yyanchiy@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

5 participants