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

Warning on autocomplete messes up the terminal #119205

Closed
JelleZijlstra opened this issue May 20, 2024 · 13 comments
Closed

Warning on autocomplete messes up the terminal #119205

JelleZijlstra opened this issue May 20, 2024 · 13 comments
Labels
3.13 bugs and security fixes topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error

Comments

@JelleZijlstra
Copy link
Member

JelleZijlstra commented May 20, 2024

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

@JelleZijlstra JelleZijlstra added type-bug An unexpected behavior, bug, or error 3.13 bugs and security fixes topic-repl Related to the interactive shell labels May 20, 2024
@eugenetriguba
Copy link
Contributor

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

@JelleZijlstra
Copy link
Member Author

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

@eugenetriguba
Copy link
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
Copy link

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

@koxudaxi
Copy link
Contributor

koxudaxi commented May 20, 2024

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
Copy link
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
Copy link
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.

koxudaxi added a commit to koxudaxi/cpython that referenced this issue May 20, 2024
koxudaxi added a commit to koxudaxi/cpython that referenced this issue May 20, 2024
@danielhollas
Copy link
Contributor

danielhollas commented May 20, 2024

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

EDIT: Similar issue for the old REPL
#113978

koxudaxi added a commit to koxudaxi/cpython that referenced this issue May 20, 2024
koxudaxi added a commit to koxudaxi/cpython that referenced this issue May 20, 2024
koxudaxi added a commit to koxudaxi/cpython that referenced this issue May 20, 2024
@koxudaxi
Copy link
Contributor

koxudaxi commented May 20, 2024

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

We should think about the direction of the solution.

koxudaxi added a commit to koxudaxi/cpython that referenced this issue May 20, 2024
@eugenetriguba
Copy link
Contributor

@koxudaxi Would this also resolve this issue? https://github.com/python/cpython/pull/113979/files

@koxudaxi
Copy link
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
Copy link
Contributor

ambv commented May 21, 2024

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

ambv added a commit that referenced this issue May 21, 2024
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 22, 2024
(cherry picked from commit 506b1a3)

Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
lysnikolaou pushed a commit that referenced this issue May 22, 2024
…9407)

(cherry picked from commit 506b1a3)

Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
@lysnikolaou
Copy link
Contributor

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

estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

7 participants