Skip to content

Warning on autocomplete messes up the terminal #119205

Description

@JelleZijlstra

Bug report

Bug description:

  1. Open ./python.exe
  2. import sys; code = sys._getframe(1).f_code
  3. Type code.co_ and hit tab
  4. This:
Screenshot 2024-05-20 at 6 52 31 AM

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

Activity

added
type-bugAn unexpected behavior, bug, or error
3.13only security fixes
topic-replRelated to the interactive shell
on May 20, 2024

eugenetriguba commented on May 20, 2024

@eugenetriguba
Contributor

@JelleZijlstra Are you handling this or do you mind if I take a look into this? 🙂

JelleZijlstra commented on May 20, 2024

@JelleZijlstra
MemberAuthor

I'm not, feel free to take a look!

eugenetriguba commented on May 20, 2024

@eugenetriguba
Contributor

fwiw, this looks to be an issue with any output:

>>> import tarfile
>>> t = tarfile.TarInfo()
>>> t.tarfile.T<string>:1: DeprecationWarning: The undocumented "tarfile" attribute of TarInfo objects is deprecated and will be removed in Python 3.16

I ran into a similar issue when bringing up pdb:

 % ./python.exe
Python 3.14.0a0 (heads/main:16b46ebd2b, May 20 2024, 08:24:14) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.> /Users/eugene/src/cpython/Lib/rlcompleter.py(76)complete()
                                                                   -> breakpoint()
                                                                                  (Pdb) l

jima80525 commented on May 20, 2024

@jima80525

Just found that this happens on mac, but not ubuntu. New repl doesn't have a windows version with autocomplete.

koxudaxi commented on May 20, 2024

@koxudaxi
Contributor

mac uses /usr/lib/libedit.3.dylib for readline
But, ubuntu uses libreadline.so.8 of GNU.

dyld_info Modules/readline.cpython-314d-darwin.so 
Modules/readline.cpython-314d-darwin.so [arm64]:
    -platform:
        platform     minOS      sdk
           macOS     14.4      14.4   
    -segments:
        load-offset   segment section        sect-size  seg-size perm
        0x00000000    __TEXT                                32KB r.x
        0x00004110             __text             9476
        0x00006614             __stubs             948
        0x000069C8             __stub_helper       972
        0x00006D94             __cstring          1194
        0x00007240             __const            3296
        0x00007F20             __unwind_info       224
        0x00008000    __DATA_CONST                          16KB rw.
        0x00008000             __got               224
        0x0000C000    __DATA                                16KB rw.
        0x0000C000             __la_symbol_ptr     632
        0x0000C278             __data              984
        0x0000C650             __bss                32
    -dependents:
        attributes     load path
                       /usr/lib/libedit.3.dylib
                       /usr/lib/libSystem.B.dylib

koxudaxi commented on May 20, 2024

@koxudaxi
Contributor

I re-build with GNU readline lib. But, The bug reproduce :(

brew install readline
export LDFLAGS="-L/opt/homebrew/opt/readline/lib"
export CPPFLAGS="-I/opt/homebrew/opt/readline/include"
./configure --with-pydebug --with-readline=readline
...

dyld_info Modules/readline.cpython-314d-darwin.so 
Modules/readline.cpython-314d-darwin.so [arm64]:
    -platform:
        platform     minOS      sdk
           macOS     14.4      14.4   
    -segments:
        load-offset   segment section        sect-size  seg-size perm
        0x00000000    __TEXT                                32KB r.x
        0x00003E10             __text             9928
        0x000064D8             __stubs            1008
        0x000068C8             __stub_helper      1032
        0x00006CD0             __cstring          1214
        0x00007190             __const            3456
        0x00007F10             __unwind_info       232
        0x00008000    __DATA_CONST                          16KB rw.
        0x00008000             __got               240
        0x0000C000    __DATA                                16KB rw.
        0x0000C000             __la_symbol_ptr     672
        0x0000C2A0             __data             1016
        0x0000C698             __bss                40
    -dependents:
        attributes     load path
                       /opt/homebrew/opt/readline/lib/libreadline.8.dylib
                       /usr/lib/libSystem.B.dylib

eugenetriguba commented on May 20, 2024

@eugenetriguba
Contributor

I tried this with pypy and wasn't able to get this output with the latest version:

~ % pypy
Python 3.10.14 (75b3de9d9035, Apr 21 2024, 10:55:50)
[PyPy 7.3.16 with GCC Apple LLVM 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>> import sys; code = sys._getframe(1).f_code
code.co_argcount         code.co_filename         code.co_kwonlyargcount   code.co_name             code.co_stacksize
code.co_cellvars         code.co_firstlineno      code.co_lines()          code.co_names            code.co_varnames
code.co_code             code.co_flags            code.co_linetable        code.co_nlocals
code.co_consts           code.co_freevars         code.co_lnotab           code.co_posonlyargcount
>>>> code.co_

But I'm not sure pypy has that deprecation warning in this codepath so I'll check that.

added 2 commits that reference this issue on May 20, 2024

danielhollas commented on May 20, 2024

@danielhollas
Contributor

Hmm, it seems that similar behaviour exists on the old terminal as well though.

EDIT: Similar issue for the old REPL
#113978

added 3 commits that reference this issue on May 20, 2024

koxudaxi commented on May 20, 2024

@koxudaxi
Contributor

@danielhollas
Thank you for sharing the issue.
I think it's the same root cause.

We should think about the direction of the solution.

added a commit that references this issue on May 20, 2024

eugenetriguba commented on May 21, 2024

@eugenetriguba
Contributor

koxudaxi commented on May 21, 2024

@koxudaxi
Contributor

@eugenetriguba
I think so. We confirmed that the problem will only happen with MacOS.
But, the solution works for all environments.
Should I close my PR as a duplicate?

ambv commented on May 21, 2024

@ambv
Contributor

@koxudaxi, sign the CLA and I think we will still take your PR as it includes a test.

added a commit that references this issue on May 21, 2024
added a commit that references this issue on May 22, 2024
added a commit that references this issue on May 22, 2024

lysnikolaou commented on May 22, 2024

@lysnikolaou
Member

Thanks all for the input and @koxudaxi for the PR.

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

    3.13only security fixestopic-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