Skip to content

Deprecation warning during text completion in REPL #113978

Description

@WolframAlph

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

Activity

  1. added a commit that references this issue on Jan 12, 2024
  2. terryjreedy commented on Jan 12, 2024

    @terryjreedy
    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.

  3. gaogaotiantian commented on Jan 17, 2024

    @gaogaotiantian
    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.

  4. added a commit that references this issue on May 21, 2024
  5. ambv commented on May 21, 2024

    @ambv
    Contributor

    Thanks! ✨ 🍰 ✨

  6. added a commit that references this issue on May 22, 2024
  7. added a commit that references this issue on May 22, 2024
  8. added a commit that references this issue on Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions