-
Notifications
You must be signed in to change notification settings - Fork 229
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
Ctrl-x not function to leave console #166
Comments
I can't reproduce this, so this likely has something to do with your setup. On Linux, with vte (gnome terminal), konsole, and xterm, this works just fine for me. Can you try through both display drivers (raw/curses) in the pref screen and see if that helps? |
Changing to curses seems to have fixed it. Thanks. |
I have the same reported behavior on Mac. I am using iTerm2. |
Switching to curses doesn't improve the console, and makes other things bad :( |
^X used to have some flow control behavior. Can you turn that off in iTerm2? |
(I think. Actually not 100% sure about that.) |
That doesn't sound right to me. The first ^X would have that effect then, but it doesn't. And the second ^X doesn't stop the flow, it just echoes |
@asmeurer, you use (used?) iTerm2, I recall. Any clues? |
It is working for me, but I am using the iTerm2 nightly build. But it also works for me in Terminal.app. What version of urwid are you guys using? I have 1.3.1. |
Full freeze output (only some of which is for pudb):
|
BTW, I tested using the Mac Terminal app also, and it behaves the same for me as in iTerm2. |
Yeah me too, that is, it works in both. In fact, I just tried using the guest user account on my Mac to install pudb fresh, using Terminal.app, so that everything is default settings, and I still can't reproduce this. Any guesses as to what might be causing it. I also tried fiddling with different $TERM settings, but it doesn't seem to matter. |
@nedbat, whats your |
xterm-256color |
Is that what you have, @asmeurer? |
Yeah, and I tried all the other ones in the Terminal settings in my guest account. Haven't yet found any configuration that reproduces this. |
If you've got some suggestion for where in the pudb code to add some debugging information extraction, I'm game to give it a try. |
@asmeurer Yes but shell.py is lazy loaded, after its loaded problem is gone but its quite annoying to open shell every time user wants to debug something. |
According to #191, importing readline at the top of debugger.py fixes the issue. When I start pudb and go straight to the console and type import sys
sys.modules['readline'] it's there, meaning it's already been imported. Is it the same for you? |
OK, it seems that |
I don't have this issue on another machine as well, this is happening only on this system (El Capitan 10.11.5). Im not familiar with this project but maybe when readline is imported, other library (urwid? subprocess?) uses this library to read line instead of something else and this is why it works? Surely if we try to read line from console even once before library gets imported, screen gets corrupted. |
I just noticed that this problem seems to be fixed now? I have iTerm2 v3.0.12 |
Thanks for the update. It doesn't feel like we meaningfully got to the bottom of what was causing this--but I'm glad to hear it's no longer occurring for you. It'd be tempting to just blame it on some external circumstance and move on, but I'm not sure I'm confident it won't rear its head again at some point. Let's just leave this open for now. |
Having the same issue. $TERM: xterm-256color Using GNU Screen (Problem still happens with GNU Screen off) Just tried iTerm 3.0.14. Still has the bug |
Didn't think of this before, but maybe the version of readline has something to do with it. What does this give you (may not work if you don't have the developer tools installed)? import readline
import subprocess
subprocess.call(["otool", "-L", readline._rl.__file__]) |
If that gives an error about import readline
import subprocess
subprocess.call(["otool", "-L", readline.__file__]) |
Ctrl-X works for me currently, and here's my readline data point:
|
Here's the output Python 2.7.13 (default, Dec 18 2016, 07:03:39)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import readline
>>> import subprocess
>>> subprocess.call(['otool', '-L', readline._rl.__file__])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '_rl'
>>> subprocess.call(['otool', '-L', readline.__file__])
/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so:
/usr/local/opt/readline/lib/libreadline.7.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)
0
>>> |
Not sure if it makes any difference but here's they py3 output. I don't have any issues using this with pudb. Any other thing I should try to get pudb working again in py2? Don't like using other debuggers beside this one \o/ Python 3.6.0 (default, Dec 24 2016, 08:01:42)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import readline
>>> import subprocess
>>> subprocess.call(["otool", "-L", readline._rl.__file__])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'readline' has no attribute '_rl'
>>> subprocess.call(["otool", "-L", readline.__file__])
/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload/readline.cpython-36m-darwin.so:
/usr/local/opt/readline/lib/libreadline.7.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)
0
>>> |
Sorry but still having this issue :(. It gets solved doing what @asmeurer said (#166 (comment)). Im on py 2.7.10, pudb 2018.1 and iTerm2 3.2.6.... I'm missing something? |
The issues with using a custom dict subclass to eval/exec are fixed in Python 3. Without this, local functions in the shell cannot access global variables (for instance, inside of list comprehentions). See the discussion on issues inducer#166 and inducer#103.
The issues with using a custom dict subclass to eval/exec are fixed in Python 3. Without this, local functions in the shell cannot access global variables (for instance, inside of list comprehensions). See the discussion on issues inducer#166 and inducer#103.
I'm still seeing this issue. |
@scirelli what version of pudb and Python are you using? |
pudb: 2019.1 |
Maybe my diagnosis of the source of the problem was incorrect. Which makes sense because it was never really clear to me how the globals() dict behavior could cause issues with urwid. Can you give me more info about your system. What OS is it, and what Python are you using (system Python, python.org, anaconda...)? Also do the exact steps from #166 (comment) reproduce the issue for you? |
Mac, Python.org, just debugging using the cli All I have to do to reproduce is press <Ctrl+x>, try to execute a statement, then try to switch back to source with <Ctrl+x> again. It won't work and I'll start seeing control codes ^X etc. printed. They are printed outside of pudb. It's like pudb is not refreshing, typing enough characters and it'll scroll the previous text (pudb UI) up the screen. The only thing I can do is kill Python/pudb. I think if I hit enter enough times...not sure what causes it...but it'll try to execute everything I typed. I'll provide more info tomorrow, I'm not in front of that computer right now. I was not having this problem a few weeks ago. I don't think this started happening until I updated to 2019.1. I was on 2018.1. I'll try to revert back to see what happens. |
@asmeurer Backspace wasn't working either. I install pudb 2018.1 and it works fine. Looks like it's just something in the new version. |
I'll check if I can reproduce this later (I need to install the python.org Python 3 on my Mac). It's also good to see that you are using a virtualenv. That may be relevant. |
I see it happening in 2018.1 when I hit the tab key to auto complete a variable name. |
I was able to reproduce this with the python.org Python 3 on my Mac. I also got a traceback which sent me to post-mortem mode: Traceback (most recent call last):
File "/Users/aaronmeurer/Documents/pudb/pudb/__init__.py", line 152, in runscript
dbg._runscript(mainpyfile)
File "/Users/aaronmeurer/Documents/pudb/pudb/debugger.py", line 468, in _runscript
self.run(statement)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/bdb.py", line 585, in run
exec(cmd, globals, locals)
File "<string>", line 1, in <module>
File "test.py", line 3, in <module>
import pudb
File "test.py", line 3, in <module>
import pudb
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/bdb.py", line 88, in
trace_dispatch
return self.dispatch_line(frame)
File "/Users/aaronmeurer/Documents/pudb/pudb/debugger.py", line 189, in dispatch_line
self.user_line(frame)
File "/Users/aaronmeurer/Documents/pudb/pudb/debugger.py", line 410, in user_line
self.interaction(frame)
File "/Users/aaronmeurer/Documents/pudb/pudb/debugger.py", line 378, in interaction
show_exc_dialog=show_exc_dialog)
File "/Users/aaronmeurer/Documents/pudb/pudb/debugger.py", line 2147, in call_with_ui
return f(*args, **kwargs)
File "/Users/aaronmeurer/Documents/pudb/pudb/debugger.py", line 2400, in interaction
self.event_loop()
File "/Users/aaronmeurer/Documents/pudb/pudb/debugger.py", line 2360, in event_loop
keys = self.screen.get_input()
File
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urwid/raw_display.py",
line 336, in get_input
keys, raw = self.parse_input(None, None, self.get_available_raw_input())
File
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urwid/raw_display.py",
line 436, in get_available_raw_input
codes = self._get_gpm_codes() + self._get_keyboard_codes()
File
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urwid/raw_display.py",
line 510, in _get_keyboard_codes
code = self._getch_nodelay()
File
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urwid/raw_display.py",
line 644, in _getch_nodelay
return self._getch(0)
File
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urwid/raw_display.py",
line 554, in _getch
return ord(os.read(self._term_input_file.fileno(), 1))
TypeError: ord() expected a character, but string of length 0 found (also annoyingly, the exception viewer did not have the option to save the traceback to a file) |
Bisected the problem, and unsurprisingly, this is the bad commit:
So it seems my theory that this issue should only occur in Python 2 was wrong. There is something about the system Python that is at issue here, as it doesn't do it for me with the Anaconda Python. |
Maybe it has to do with the python.org Python (and also the system Python) using libedit instead of readline. Which means it could be related to #337. |
It's definitely readline. If I remove the readline imports in shell.py, the issue goes away. #337 doesn't fix it however. |
This fixes inducer#166. I have no idea why, but if readline is really libedit (like for a system or python.org install on Mac), it causes the built in shell to break the terminal inputs, but only when imported at the top level. If the import is deferred, as far as I've seen, it doesn't happen.
I'm having this same problem using the latest version of pudb and iterm2 on a Mac (I'm also using the curses shell in pudb). To reproduce the issue I just have to run pudb main.py, then hit ctrl-x or "!" to enter the python shell, then type some gibberish and click enter. Backspace stops working and ctrl-x appears in the prompt. It seems like ctrl-x does actually work (even though it doesn't appear to be working visually) because hitting ctrl-X then 'n' then will actually exit the shell and go to the next line as expected. Once the UI updates the issue will be fixed for the rest of the session and the shell works as expected |
I'm just now running into this. pudb was working fine for my under Python 2.7. I only noticed this when moving to Python 3. I"m using Terminal.app. Other than that, I have nothing useful to contribute. |
Can you check if #350 fixes the problem? |
Yep, that fixed it |
@asmeurer I also ran into this issue using Python 3.8.0 and Kitty terminal on MacOS. I've just tried out your patch and can confirm it fixes the issue for me. |
I am having the same issue, I can't exit from the command line using ctrl x after writing something |
When attempting to make local calls in the console, pressing ctrl-x merely prints
^x
rather than leaving the console. At this point, the only way out is to kill pudb. An interesting behavior is that this only happens after issuing a command in the console; ctrl-x works fine until then.Details:
pudb version: 2015.4.1
installed with pip
running in osx 10.11.2 in iTerm2, Terminal, and Neovim's terminal mode
The text was updated successfully, but these errors were encountered: