[issue29396] Re-opening /dev/tty breaks readline
Silvio Ricardo Cordeiro added the comment: So, if I understood correctly, the `readline` module only works for an unmodified `sys.stdin`, which is implemented in terms of C `FILE*` structures. Anything created by `open` will not be implemented in terms of C `FILE*`, and so all history and completion features of `readline` will be (silently) disabled. Is there any workaround to make `open` (or some other file-opening function) return a file object wrapping a C `FILE*`? Maybe this behavior should be documented in the `readline` documentation? (https://docs.python.org/3/library/readline.html) -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29396> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29396] Re-opening /dev/tty breaks readline
New submission from Silvio Ricardo Cordeiro: The following code works on python2 (tested with 2.7.6), but breaks readline for python3 (tested with 3.4.3): >>> import sys, readline >>> sys.stdin = open('/dev/tty', 'r') >>> input("> ") # press "7" >>> input("> ") # press "up" key Re-opening /dev/tty as stdin is a very useful technique. For example, one could debug a script that takes a file as stdin by re-opening the stdin as /dev/tty and using pdb.set_trace(). See bug report for python2 in 2002 here: https://bugs.python.org/issue512981 -- components: Library (Lib) messages: 286521 nosy: silvioricardoc priority: normal severity: normal status: open title: Re-opening /dev/tty breaks readline versions: Python 3.4 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29396> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1539381] Add readinto method to StringIO and cStringIO
Silvio Ricardo Cordeiro added the comment: BufferedReader assumes that readinto is defined, but that's not the case for StringIO's. In the end, this cripples StringIO objects, because their data can never be peek()'ed as with all other file objects. -- components: +IO -Library (Lib) nosy: +silvioricardoc type: - behavior versions: +Python 2.7, Python 3.2 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1539381 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10728] argparse.ArgumentParser.print_help uses sys.stdout
New submission from Silvio Ricardo Cordeiro silvioricar...@gmail.com: The documentation at http://docs.python.org/dev/library/argparse.html explicitly says that If file is None, sys.stderr is assumed. However, both print_usage and print_help assume sys.stdout when file=None. The helper method _print_message actually does it right, when called with file=None. -- components: Library (Lib) messages: 124271 nosy: silvioricardoc priority: normal severity: normal status: open title: argparse.ArgumentParser.print_help uses sys.stdout type: behavior versions: Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10728 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com