-
-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Pasting into Python REPL broken in recent brew Python builds #68193
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Looking into it some more: Anaconda Python3.9 doesn't have this bug. Building Python3.9 from source using the release tarball with
doesn't have this bug either. |
Maybe it has something to do with how we specifically want Homebrew homebrew-core/Formula/python@3.9.rb Lines 142 to 146 in f257d87
I wonder if without this modification, we just use system |
Checked Anaconda Python3.9 uses readline 8.0. |
Yep, almost definitely a readline 8.1 bug (or, well, an rlwrap bug which readline exposes): https://lists.gnu.org/archive/html/bug-readline/2020-12/msg00002.html Here's a workaround (suggested by the upstream bug report):
Note: if you use |
Do we want to change the default when configuring
|
We don't want to change the default, and caveats are for things that are specific to homebrew. Let's see how the readline/rlwrap people fix that. |
rlwrap is for now changing the default hanslub42/rlwrap#108 |
but python@3.9 doesn't use rlwrap, does it? |
My understanding is that python@3.9 uses readline, and readline uses rlwrap. However, I'm not sure how the change in rlwrap defaults in
affects readline defaults. |
I think rlwrap uses readline:
|
Hm, ok. So perhaps there is a separate bug in readline? Turning off bracketed paste fixes the issue for me. |
My guess is that the default changed in readline 8.1 which affected both rlwrap and python. I don't think it's a readline bug (but it may be) -- most likely a python bug. |
My suggestion would be to file a Python issue for incompatibility with readline 8.1 |
I compiled python3.9 again straight out of the source tarball (with Can't reproduce the issue. It still behaves weird though:
|
Looking a little more, I don't think this is even necessarily a python bug. Rather, this is due to Python not supporting bracketed paste mode and GNU readline enabling bracketed paste mode by default in 8.1. If you rebuild readline with the 8.0 source, paste works as it did before. If you set See also https://bugs.python.org/issue39820, https://bugs.python.org/issue32019 |
That makes sense. That Homebrew ships Python with a version of readline that has bracketed-paste mode on by default, therefore creating known incompatibilities with Python, seems Homebrew-specific, then. (Cf. Anaconda, and python.org Python) Might be worth a caveat after all? |
It's not Homebrew-specific, it's just that python doesn't support readline 8.1 in its default setting. As far as I see, nobody has reported it to Python, so they're not likely to fix it… this really is step 1, we can discuss all we want but it is not going to achieve anything. Either a new bug report is opened, or someone adds the key information to the existing bug reports: "python linked against latest readline in default settings is broken". Then python can figure out what they want to do: add support for bracketed paste, disable bracketed paste, forbid readline… and we can act accordingly. |
I'm not sure that this should be a caveat -- if we were pinned to a non-current version of readline, then maybe, but since this is the current version then this isn't Homebrew specific. For example, the python installed by the latest version of Arch Linux also has the same behavior:
|
Reported to Python - https://bugs.python.org/issue42819 |
PR submitted - python/cpython#24108 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Bug report
brew update
and can still reproduce the problem?brew doctor
, fixed all issues and can still reproduce the problem?brew config
andbrew doctor
output appended at the end.What you were trying to do (and why)
Paste multiple lines of text in a terminal into the Python REPL.
What happened (include command output)
Instead of each line being seen as a separate line, it seems to treat the whole paste as one big line. This is a change from earlier Brew builds of Python.
What you expected to happen
Here is what happens using the same version of Python, but installed via the installer from python.org instead of via Brew:
That's also what happens using Apple's python3.
Step-by-step reproduction instructions (by running
brew install
commands)brew install python3
The same problem occurs if you install python@3.8 or python@3.7 via Brew, so this does not seem to be something specific to the relatively new python 3.9.
This problem did not occur 6 to 8 weeks ago.
It is not some sort of problem with the terminal itself. It occurs in Apple's Terminal, iTerm2, and xterm.
One thing that might provide a clue: if pasting something that contains tabs and using iTerm2, iTerm2 normally puts up a dialog asking what to do with the tabs. It is no longer asking when pasting into Brew python. That suggests that whatever has changed in the Brew python builds recently is something that iTerm2 can notice, suggesting the problem is something to do with how python is initializing the tty.
Before posting the issue, I brought this up on the discussion forums to get a sanity check in case I was just doing something stupid, and someone else was able to reproduce it on Brew python 3.8 and 3.9. Here is that discussion in case it might be helpful: Homebrew/discussions#428
Brew config output:
Brew doctor output:
The text was updated successfully, but these errors were encountered: